Skip to content

Commit

Permalink
Ensure built-in directives have lowest priority (#2403)
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia authored May 23, 2023
1 parent 5ef5976 commit b26fb27
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ You can find and compare releases at the [GitHub release page](https://github.co

## Unreleased

## v6.9.1

### Fixed

- Ensure built-in directives have the lowest priority in registration https://github.com/nuwave/lighthouse/pull/2403

## v6.9.0

### Added
Expand Down
4 changes: 1 addition & 3 deletions src/Http/Responses/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Nuwave\Lighthouse\Http\Responses;

use Illuminate\Support\Str;

abstract class Stream
{
/**
Expand All @@ -22,7 +20,7 @@ protected function chunkError(string $path, array $data): ?array

$errorsMatchingPath = array_filter(
$errors,
static fn (array $error): bool => Str::startsWith(implode('.', $error['path']), $path),
static fn (array $error): bool => str_starts_with(implode('.', $error['path']), $path),
);

return array_values($errorsMatchingPath);
Expand Down
2 changes: 2 additions & 0 deletions src/Schema/DirectiveLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public function namespaces(): array
]))
->flatten()
->filter()
// Ensure built-in directives come last
->sortBy(static fn (string $namespace): int => (int) str_starts_with($namespace, 'Nuwave\\Lighthouse'))
->all();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Schema/Source/SchemaStitcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected static function gatherSchemaImportsRecursively(string $path): string
{
return (new Collection(\Safe\file($path)))
->map(static function (string $line) use ($path): string {
if (! Str::startsWith(trim($line), '#import ')) {
if (! str_starts_with(trim($line), '#import ')) {
return rtrim($line, PHP_EOL) . PHP_EOL;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Subscriptions/Authorizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function authorize(Request $request): bool
*/
protected function sanitizeChannelName(string $channelName): string
{
if (Str::startsWith($channelName, 'presence-')) {
if (str_starts_with($channelName, 'presence-')) {
return Str::substr($channelName, 9);
}

Expand Down
3 changes: 1 addition & 2 deletions tests/Integration/LifecycleEventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Tests\Integration;

use Illuminate\Contracts\Events\Dispatcher as EventsDispatcher;
use Illuminate\Support\Str;
use Nuwave\Lighthouse\Events\BuildExtensionsResponse;
use Nuwave\Lighthouse\Events\BuildSchemaString;
use Nuwave\Lighthouse\Events\EndExecution;
Expand All @@ -27,7 +26,7 @@ public function testDispatchesProperLifecycleEvents(): void
$events = [];

$eventsDispatcher->listen('*', static function (string $name, array $payload) use (&$events): void {
if (Str::startsWith($name, 'Nuwave\\Lighthouse')) {
if (str_starts_with($name, 'Nuwave\\Lighthouse')) {
// We only fire class-based events, so the payload
// always holds exactly a single class instance.
$events[] = $payload[0];
Expand Down
3 changes: 1 addition & 2 deletions tests/Unit/Schema/DirectiveLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

final class DirectiveLocatorTest extends TestCase
{
/** @var \Nuwave\Lighthouse\Schema\DirectiveLocator */
protected $directiveLocator;
private DirectiveLocator $directiveLocator;

protected function setUp(): void
{
Expand Down

0 comments on commit b26fb27

Please sign in to comment.