diff --git a/CHANGELOG.md b/CHANGELOG.md index f8c78ffa42..f149e878fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ You can find and compare releases at the [GitHub release page](https://github.co ## Unreleased +## v6.49.0 + ### Added - Make reporting of client-safe errors configurable https://github.com/nuwave/lighthouse/issues/2647 diff --git a/docs/master/digging-deeper/error-handling.md b/docs/master/digging-deeper/error-handling.md index 9e7af98166..1848238d17 100644 --- a/docs/master/digging-deeper/error-handling.md +++ b/docs/master/digging-deeper/error-handling.md @@ -28,10 +28,8 @@ Client-safe errors are assumed to be something that: Thus, they are typically not actionable for server developers. -However, as Laravel allows to define a [minimum log level](https://laravel.com/docs/errors#exception-log-levels) -at which each individual log channel is triggered, you can choose to report client-safe errors by replacing -`Nuwave\Lighthouse\Execution\ReportingErrorHandler` with `Nuwave\Lighthouse\Execution\AlwaysReportingErrorHandler` -in the `lighthouse.php` config: +However, you can choose to report client-safe errors by replacing `Nuwave\Lighthouse\Execution\ReportingErrorHandler` +with `Nuwave\Lighthouse\Execution\AlwaysReportingErrorHandler` in the `lighthouse.php` config: ```diff 'error_handlers' => [ @@ -40,8 +38,7 @@ in the `lighthouse.php` config: ], ``` -When using `Nuwave\Lighthouse\Execution\AlwaysReportingErrorHandler`, client-safe exceptions will be passed to the -default Laravel exception handler, allowing you to configure appropriate error reporting outside of Lighthouse. +`Nuwave\Lighthouse\Execution\AlwaysReportingErrorHandler` reports all errors through the default Laravel exception handler, regardless of client-safety. ## Additional Error Information diff --git a/src/Bind/BindDefinition.php b/src/Bind/BindDefinition.php index ebf3075087..84037a4bc5 100644 --- a/src/Bind/BindDefinition.php +++ b/src/Bind/BindDefinition.php @@ -28,9 +28,7 @@ public function validate( $parentNodeName = $parentNode->name->value; if (! class_exists($this->class)) { - throw new DefinitionException( - "@bind argument `class` defined on `{$parentNodeName}.{$nodeName}` must be an existing class, received `{$this->class}`.", - ); + throw new DefinitionException("@bind argument `class` defined on `{$parentNodeName}.{$nodeName}` must be an existing class, received `{$this->class}`."); } if ($this->isModelBinding()) { @@ -42,9 +40,7 @@ public function validate( } $modelClass = Model::class; - throw new DefinitionException( - "@bind argument `class` defined on `{$parentNodeName}.{$nodeName}` must extend {$modelClass} or define the method `__invoke`, but `{$this->class}` does neither.", - ); + throw new DefinitionException("@bind argument `class` defined on `{$parentNodeName}.{$nodeName}` must extend {$modelClass} or define the method `__invoke`, but `{$this->class}` does neither."); } public function isModelBinding(): bool diff --git a/src/Events/StartExecution.php b/src/Events/StartExecution.php index 9b5a056c61..711254f2ce 100644 --- a/src/Events/StartExecution.php +++ b/src/Events/StartExecution.php @@ -22,24 +22,20 @@ public function __construct( * The parsed schema. */ public Schema $schema, - /** * The client given parsed query string. */ public DocumentNode $query, - /** * The client given variables, neither validated nor transformed. * * @var array|null */ public ?array $variables, - /** * The client given operation name. */ public ?string $operationName, - /** * The context for the operation. */ diff --git a/src/Execution/AlwaysReportingErrorHandler.php b/src/Execution/AlwaysReportingErrorHandler.php index 754e5b7b78..51cb46fe15 100644 --- a/src/Execution/AlwaysReportingErrorHandler.php +++ b/src/Execution/AlwaysReportingErrorHandler.php @@ -5,6 +5,7 @@ use GraphQL\Error\Error; use Illuminate\Contracts\Debug\ExceptionHandler; +/** Report all errors through the default Laravel exception handler. */ class AlwaysReportingErrorHandler implements ErrorHandler { public function __construct( diff --git a/src/GraphQL.php b/src/GraphQL.php index 36e71f3e02..343515cceb 100644 --- a/src/GraphQL.php +++ b/src/GraphQL.php @@ -315,15 +315,7 @@ public function loadPersistedQuery(string $sha256hash): DocumentNode || ! ($cacheConfig['enable'] ?? false) ) { // https://github.com/apollographql/apollo-server/blob/37a5c862261806817a1d71852c4e1d9cdb59eab2/packages/apollo-server-errors/src/index.ts#L240-L248 - throw new Error( - 'PersistedQueryNotSupported', - null, - null, - [], - null, - null, - ['code' => 'PERSISTED_QUERY_NOT_SUPPORTED'], - ); + throw new Error('PersistedQueryNotSupported', null, null, [], null, null, ['code' => 'PERSISTED_QUERY_NOT_SUPPORTED']); } $cacheFactory = Container::getInstance()->make(CacheFactory::class); @@ -331,15 +323,7 @@ public function loadPersistedQuery(string $sha256hash): DocumentNode return $store->get("lighthouse:query:{$sha256hash}") // https://github.com/apollographql/apollo-server/blob/37a5c862261806817a1d71852c4e1d9cdb59eab2/packages/apollo-server-errors/src/index.ts#L230-L239 - ?? throw new Error( - 'PersistedQueryNotFound', - null, - null, - [], - null, - null, - ['code' => 'PERSISTED_QUERY_NOT_FOUND'], - ); + ?? throw new Error('PersistedQueryNotFound', null, null, [], null, null, ['code' => 'PERSISTED_QUERY_NOT_FOUND']); } /** @return ErrorsHandler */ diff --git a/src/Pagination/PaginationArgs.php b/src/Pagination/PaginationArgs.php index 520fe33937..bbd9352b85 100644 --- a/src/Pagination/PaginationArgs.php +++ b/src/Pagination/PaginationArgs.php @@ -39,9 +39,7 @@ public static function extractArgs(array $args, ResolveInfo $resolveInfo, Pagina : Arr::get($args, 'page', 1); if ($first < 0) { - throw new Error( - self::requestedLessThanZeroItems($first), - ); + throw new Error(self::requestedLessThanZeroItems($first)); } // Make sure the maximum pagination count is not exceeded @@ -49,9 +47,7 @@ public static function extractArgs(array $args, ResolveInfo $resolveInfo, Pagina $paginateMaxCount !== null && $first > $paginateMaxCount ) { - throw new Error( - self::requestedTooManyItems($paginateMaxCount, $first), - ); + throw new Error(self::requestedTooManyItems($paginateMaxCount, $first)); } $optimalPaginationType = self::optimalPaginationType($proposedPaginationType, $resolveInfo); diff --git a/src/Schema/AST/ASTBuilder.php b/src/Schema/AST/ASTBuilder.php index 97531f28ef..45ff5b5b47 100644 --- a/src/Schema/AST/ASTBuilder.php +++ b/src/Schema/AST/ASTBuilder.php @@ -144,9 +144,7 @@ protected function extendObjectLikeType(string $typeName, ObjectTypeExtensionNod $extendedObjectLikeType = Parser::objectTypeDefinition(/** @lang GraphQL */ "type {$typeName}"); $this->documentAST->setTypeDefinition($extendedObjectLikeType); } else { - throw new DefinitionException( - $this->missingBaseDefinition($typeName, $typeExtension), - ); + throw new DefinitionException($this->missingBaseDefinition($typeName, $typeExtension)); } } diff --git a/src/Schema/AST/ASTHelper.php b/src/Schema/AST/ASTHelper.php index 4f19ad1368..80656b39a5 100644 --- a/src/Schema/AST/ASTHelper.php +++ b/src/Schema/AST/ASTHelper.php @@ -71,9 +71,7 @@ public static function mergeUniqueNodeList(NodeList|array $original, NodeList|ar $oldName = $definition->name->value; $collisionOccurred = in_array($oldName, $newNames); if ($collisionOccurred && ! $overwriteDuplicates) { - throw new DefinitionException( - static::duplicateDefinition($oldName), - ); + throw new DefinitionException(static::duplicateDefinition($oldName)); } return $collisionOccurred; @@ -342,11 +340,7 @@ public static function extractDirectiveDefinition(string $definitionString): Dir try { $document = Parser::parse($definitionString); } catch (SyntaxError $syntaxError) { - throw new DefinitionException( - "Encountered syntax error while parsing this directive definition:\n\n{$definitionString}", - $syntaxError->getCode(), - $syntaxError, - ); + throw new DefinitionException("Encountered syntax error while parsing this directive definition:\n\n{$definitionString}", $syntaxError->getCode(), $syntaxError); } /** @var \GraphQL\Language\AST\DirectiveDefinitionNode|null $directive */ diff --git a/src/Schema/DirectiveLocator.php b/src/Schema/DirectiveLocator.php index 7917b7f50e..fa9105f36a 100644 --- a/src/Schema/DirectiveLocator.php +++ b/src/Schema/DirectiveLocator.php @@ -63,11 +63,11 @@ public function namespaces(): array // Built-in and plugin defined directives come next $this->eventsDispatcher->dispatch(new RegisterDirectiveNamespaces()), ])) - ->flatten() - ->filter() - // Ensure built-in directives come last - ->sortBy(static fn (string $namespace): int => (int) str_starts_with($namespace, 'Nuwave\\Lighthouse')) - ->all(); + ->flatten() + ->filter() + // Ensure built-in directives come last + ->sortBy(static fn (string $namespace): int => (int) str_starts_with($namespace, 'Nuwave\\Lighthouse')) + ->all(); } /** diff --git a/src/Schema/Directives/BaseDirective.php b/src/Schema/Directives/BaseDirective.php index 776809f621..b19a3434bd 100644 --- a/src/Schema/Directives/BaseDirective.php +++ b/src/Schema/Directives/BaseDirective.php @@ -217,9 +217,7 @@ protected function getMethodArgumentParts(string $argumentName): array count($argumentParts) > 2 || empty($argumentParts[0]) ) { - throw new DefinitionException( - "Directive '{$this->name()}' must have an argument '{$argumentName}' in the form 'ClassName@methodName' or 'ClassName'", - ); + throw new DefinitionException("Directive '{$this->name()}' must have an argument '{$argumentName}' in the form 'ClassName@methodName' or 'ClassName'"); } /** @var array{0: string, 1?: string} $argumentParts */ diff --git a/src/Schema/Directives/ScopeDirective.php b/src/Schema/Directives/ScopeDirective.php index bb2dd8d0c2..acb3013eae 100644 --- a/src/Schema/Directives/ScopeDirective.php +++ b/src/Schema/Directives/ScopeDirective.php @@ -36,11 +36,7 @@ public function handleBuilder(QueryBuilder|EloquentBuilder|Relation $builder, $v try { return $builder->{$scope}($value); } catch (\BadMethodCallException $badMethodCallException) { - throw new DefinitionException( - "{$badMethodCallException->getMessage()} in @{$this->name()} directive on {$this->nodeName()} argument.", - $badMethodCallException->getCode(), - $badMethodCallException->getPrevious(), - ); + throw new DefinitionException("{$badMethodCallException->getMessage()} in @{$this->name()} directive on {$this->nodeName()} argument.", $badMethodCallException->getCode(), $badMethodCallException->getPrevious()); } } } diff --git a/src/Schema/Source/SchemaStitcher.php b/src/Schema/Source/SchemaStitcher.php index 61a788da3a..b46d1447d4 100644 --- a/src/Schema/Source/SchemaStitcher.php +++ b/src/Schema/Source/SchemaStitcher.php @@ -14,9 +14,7 @@ class SchemaStitcher implements SchemaSourceProvider public function __construct(string $rootSchemaPath) { if (! file_exists($rootSchemaPath)) { - throw new FileNotFoundException( - "Failed to find a GraphQL schema file at {$rootSchemaPath}. If you just installed Lighthouse, run php artisan vendor:publish --tag=lighthouse-schema", - ); + throw new FileNotFoundException("Failed to find a GraphQL schema file at {$rootSchemaPath}. If you just installed Lighthouse, run php artisan vendor:publish --tag=lighthouse-schema."); } $this->rootSchemaPath = $rootSchemaPath; @@ -43,11 +41,7 @@ protected static function gatherSchemaImportsRecursively(string $path): string try { $realpath = \Safe\realpath($importFilePath); } catch (FilesystemException $filesystemException) { - throw new FileNotFoundException( - "Did not find GraphQL schema import at {$importFilePath}.", - $filesystemException->getCode(), - $filesystemException, - ); + throw new FileNotFoundException("Did not find GraphQL schema import at {$importFilePath}.", $filesystemException->getCode(), $filesystemException); } return self::gatherSchemaImportsRecursively($realpath); diff --git a/src/Schema/Values/FieldValue.php b/src/Schema/Values/FieldValue.php index e98f568bc7..b4ee80c30c 100644 --- a/src/Schema/Values/FieldValue.php +++ b/src/Schema/Values/FieldValue.php @@ -45,7 +45,6 @@ class FieldValue public function __construct( /** The parent type of the field. */ protected TypeValue $parent, - /** The underlying AST definition of the field. */ protected FieldDefinitionNode $field, ) {} diff --git a/src/Support/Traits/GeneratesColumnsEnum.php b/src/Support/Traits/GeneratesColumnsEnum.php index 99d3971ebc..91f3371589 100644 --- a/src/Support/Traits/GeneratesColumnsEnum.php +++ b/src/Support/Traits/GeneratesColumnsEnum.php @@ -27,9 +27,7 @@ protected function hasAllowedColumns(): bool $hasColumnsEnum = ! is_null($this->directiveArgValue('columnsEnum')); if ($hasColumns && $hasColumnsEnum) { - throw new DefinitionException( - "The @{$this->name()} directive can only have one of the following arguments: `columns`, `columnsEnum`.", - ); + throw new DefinitionException("The @{$this->name()} directive can only have one of the following arguments: `columns`, `columnsEnum`."); } return $hasColumns || $hasColumnsEnum; diff --git a/src/Testing/MakesGraphQLRequests.php b/src/Testing/MakesGraphQLRequests.php index 18531097d2..a46eb0eea3 100644 --- a/src/Testing/MakesGraphQLRequests.php +++ b/src/Testing/MakesGraphQLRequests.php @@ -242,7 +242,7 @@ protected function setUpSubscriptionEnvironment(): void $config->set('lighthouse.subscriptions.storage_ttl', null); // binding an instance to the container, so it can be spied on - $app->bind(Broadcaster::class, static fn (ConfigRepository $config): \Nuwave\Lighthouse\Subscriptions\Broadcasters\LogBroadcaster => new LogBroadcaster( + $app->bind(Broadcaster::class, static fn (ConfigRepository $config): LogBroadcaster => new LogBroadcaster( $config->get('lighthouse.subscriptions.broadcasters.log'), )); diff --git a/src/Testing/MakesGraphQLRequestsLumen.php b/src/Testing/MakesGraphQLRequestsLumen.php index ea73d6e7c2..4c73017f08 100644 --- a/src/Testing/MakesGraphQLRequestsLumen.php +++ b/src/Testing/MakesGraphQLRequestsLumen.php @@ -261,7 +261,7 @@ protected function setUpSubscriptionEnvironment(): void $config->set('lighthouse.subscriptions.storage_ttl', null); // binding an instance to the container, so it can be spied on - $app->bind(Broadcaster::class, static fn (ConfigRepository $config): \Nuwave\Lighthouse\Subscriptions\Broadcasters\LogBroadcaster => new LogBroadcaster( + $app->bind(Broadcaster::class, static fn (ConfigRepository $config): LogBroadcaster => new LogBroadcaster( $config->get('lighthouse.subscriptions.broadcasters.log'), )); diff --git a/src/Testing/TestsSubscriptions.php b/src/Testing/TestsSubscriptions.php index 320cf2378e..5b275f843a 100644 --- a/src/Testing/TestsSubscriptions.php +++ b/src/Testing/TestsSubscriptions.php @@ -21,7 +21,7 @@ protected function setUpTestsSubscriptions(): void $config->set('lighthouse.subscriptions.storage_ttl', null); // binding an instance to the container, so it can be spied on - $app->bind(Broadcaster::class, static fn (ConfigRepository $config): \Nuwave\Lighthouse\Subscriptions\Broadcasters\LogBroadcaster => new LogBroadcaster( + $app->bind(Broadcaster::class, static fn (ConfigRepository $config): LogBroadcaster => new LogBroadcaster( $config->get('lighthouse.subscriptions.broadcasters.log'), )); diff --git a/src/Tracing/FederatedTracing/Proto/Trace/CachePolicy/Scope.php b/src/Tracing/FederatedTracing/Proto/Trace/CachePolicy/Scope.php index 380232793f..c5fac7c17c 100644 --- a/src/Tracing/FederatedTracing/Proto/Trace/CachePolicy/Scope.php +++ b/src/Tracing/FederatedTracing/Proto/Trace/CachePolicy/Scope.php @@ -25,11 +25,7 @@ class Scope public static function name($value) { if (! isset(self::$valueToName[$value])) { - throw new \UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', - __CLASS__, - $value, - )); + throw new \UnexpectedValueException(sprintf('Enum %s has no name defined for value %s', __CLASS__, $value)); } return self::$valueToName[$value]; @@ -41,11 +37,7 @@ public static function value($name) if (! defined($const)) { $pbconst = __CLASS__ . '::PB' . strtoupper($name); if (! defined($pbconst)) { - throw new \UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', - __CLASS__, - $name, - )); + throw new \UnexpectedValueException(sprintf('Enum %s has no value defined for name %s', __CLASS__, $name)); } return constant($pbconst); diff --git a/src/Tracing/FederatedTracing/Proto/Trace/HTTP/Method.php b/src/Tracing/FederatedTracing/Proto/Trace/HTTP/Method.php index 5961ff7ff4..2fbf80f462 100644 --- a/src/Tracing/FederatedTracing/Proto/Trace/HTTP/Method.php +++ b/src/Tracing/FederatedTracing/Proto/Trace/HTTP/Method.php @@ -46,11 +46,7 @@ class Method public static function name($value) { if (! isset(self::$valueToName[$value])) { - throw new \UnexpectedValueException(sprintf( - 'Enum %s has no name defined for value %s', - __CLASS__, - $value, - )); + throw new \UnexpectedValueException(sprintf('Enum %s has no name defined for value %s', __CLASS__, $value)); } return self::$valueToName[$value]; @@ -60,11 +56,7 @@ public static function value($name) { $const = __CLASS__ . '::' . strtoupper($name); if (! defined($const)) { - throw new \UnexpectedValueException(sprintf( - 'Enum %s has no value defined for name %s', - __CLASS__, - $name, - )); + throw new \UnexpectedValueException(sprintf('Enum %s has no value defined for name %s', __CLASS__, $name)); } return constant($const); diff --git a/tests/FakeExceptionHandler.php b/tests/FakeExceptionHandler.php index bc4a3eefbf..3db7caaee6 100644 --- a/tests/FakeExceptionHandler.php +++ b/tests/FakeExceptionHandler.php @@ -36,5 +36,5 @@ public function render($request, \Throwable $e): Response throw $e; } - public function renderForConsole($output, \Throwable $e) {} + public function renderForConsole($output, \Throwable $e): void {} } diff --git a/tests/Integration/Execution/AlwaysReportingErrorHandlerTest.php b/tests/Integration/Execution/AlwaysReportingErrorHandlerTest.php index 6e428ca4e0..570b9f9a32 100644 --- a/tests/Integration/Execution/AlwaysReportingErrorHandlerTest.php +++ b/tests/Integration/Execution/AlwaysReportingErrorHandlerTest.php @@ -4,6 +4,7 @@ use GraphQL\Error\Error; use Nuwave\Lighthouse\Execution\AlwaysReportingErrorHandler; +use PHPUnit\Framework\Attributes\Before; use Tests\FakeExceptionHandler; use Tests\TestCase; use Tests\Utils\Exceptions\ClientAwareException; @@ -12,7 +13,7 @@ final class AlwaysReportingErrorHandlerTest extends TestCase { private FakeExceptionHandler $handler; - /** @before */ + #[Before] public function fakeExceptionHandling(): void { $this->afterApplicationCreated(function (): void { @@ -48,11 +49,11 @@ public static function nonClientSafeErrors(): iterable public function testNonClientSafeErrors(\Exception $previousError): void { $error = new Error(previous: $previousError); - $next = fn (Error $error): array => \compact('error'); + $next = fn (Error $error): array => ['error' => $error]; $result = (new AlwaysReportingErrorHandler($this->handler))($error, $next); - $this->assertSame(\compact('error'), $result); + $this->assertSame(['error' => $error], $result); $this->handler->assertReported($previousError); } @@ -67,11 +68,11 @@ public static function clientSafeErrors(): iterable public function testClientSafeErrors(?\Exception $previousError): void { $error = new Error(previous: $previousError); - $next = fn (Error $error): array => \compact('error'); + $next = fn (Error $error): array => ['error' => $error]; $result = (new AlwaysReportingErrorHandler($this->handler))($error, $next); - $this->assertSame(\compact('error'), $result); + $this->assertSame(['error' => $error], $result); $this->handler->assertReported(match ($previousError) { null => $error, default => $previousError, diff --git a/tests/Integration/Execution/ReportingErrorHandlerTest.php b/tests/Integration/Execution/ReportingErrorHandlerTest.php index a3e43f6c35..f6dabe7686 100644 --- a/tests/Integration/Execution/ReportingErrorHandlerTest.php +++ b/tests/Integration/Execution/ReportingErrorHandlerTest.php @@ -4,6 +4,7 @@ use GraphQL\Error\Error; use Nuwave\Lighthouse\Execution\ReportingErrorHandler; +use PHPUnit\Framework\Attributes\Before; use Tests\FakeExceptionHandler; use Tests\TestCase; use Tests\Utils\Exceptions\ClientAwareException; @@ -12,7 +13,7 @@ final class ReportingErrorHandlerTest extends TestCase { private FakeExceptionHandler $handler; - /** @before */ + #[Before] public function fakeExceptionHandling(): void { $this->afterApplicationCreated(function (): void { @@ -48,11 +49,11 @@ public static function nonClientSafe(): iterable public function testNonClientSafeErrors(\Exception $previousError): void { $error = new Error(previous: $previousError); - $next = fn (Error $error): array => \compact('error'); + $next = fn (Error $error): array => ['error' => $error]; $result = (new ReportingErrorHandler($this->handler))($error, $next); - $this->assertSame(\compact('error'), $result); + $this->assertSame(['error' => $error], $result); $this->handler->assertReported($previousError); } @@ -67,11 +68,11 @@ public static function clientSafeErrors(): iterable public function testClientSafeErrors(?\Exception $previousError): void { $error = new Error(previous: $previousError); - $next = fn (Error $error): array => \compact('error'); + $next = fn (Error $error): array => ['error' => $error]; $result = (new ReportingErrorHandler($this->handler))($error, $next); - $this->assertSame(\compact('error'), $result); + $this->assertSame(['error' => $error], $result); $this->handler->assertNothingReported(); } } diff --git a/tests/Integration/Schema/Directives/BelongsToManyDirectiveTest.php b/tests/Integration/Schema/Directives/BelongsToManyDirectiveTest.php index 0c4815c38e..955d6efef0 100644 --- a/tests/Integration/Schema/Directives/BelongsToManyDirectiveTest.php +++ b/tests/Integration/Schema/Directives/BelongsToManyDirectiveTest.php @@ -308,9 +308,8 @@ public function testQueryBelongsToManyRelayConnectionWithCustomEdgeHavingPivotFi } } } - ') - ->assertJsonPath('data.user.roles.edges.*.pivot', array_fill(0, 2, $meta)) - ->assertJsonCount(2, 'data.user.roles.edges'); + ')->assertJsonPath('data.user.roles.edges.*.pivot', array_fill(0, 2, $meta)) + ->assertJsonCount(2, 'data.user.roles.edges'); } public function testQueryBelongsToManyPivot(): void diff --git a/tests/Integration/Schema/Directives/Fixtures/CompanyWasCreatedEvent.php b/tests/Integration/Schema/Directives/Fixtures/CompanyWasCreatedEvent.php index 2ac3b30636..ac19372bd7 100644 --- a/tests/Integration/Schema/Directives/Fixtures/CompanyWasCreatedEvent.php +++ b/tests/Integration/Schema/Directives/Fixtures/CompanyWasCreatedEvent.php @@ -6,5 +6,7 @@ final class CompanyWasCreatedEvent { - public function __construct(public Company $company) {} + public function __construct( + public Company $company, + ) {} } diff --git a/tests/Integration/Schema/Directives/HasManyDirectiveTest.php b/tests/Integration/Schema/Directives/HasManyDirectiveTest.php index 46c8d9046f..0289e89de4 100644 --- a/tests/Integration/Schema/Directives/HasManyDirectiveTest.php +++ b/tests/Integration/Schema/Directives/HasManyDirectiveTest.php @@ -1080,7 +1080,7 @@ public function testQueryHasManyNestedRelationships(): void ], ], ])->assertJsonCount(2, 'data.user.tasks.edges') - ->assertJsonCount(2, 'data.user.tasks.edges.0.node.user.tasks.edges'); + ->assertJsonCount(2, 'data.user.tasks.edges.0.node.user.tasks.edges'); } public function testQueryHasManySelfReferencingRelationships(): void diff --git a/tests/Integration/SoftDeletes/SoftDeletesAndTrashedDirectiveTest.php b/tests/Integration/SoftDeletes/SoftDeletesAndTrashedDirectiveTest.php index f607627da9..35df124629 100644 --- a/tests/Integration/SoftDeletes/SoftDeletesAndTrashedDirectiveTest.php +++ b/tests/Integration/SoftDeletes/SoftDeletesAndTrashedDirectiveTest.php @@ -355,9 +355,9 @@ public function testNested(): void } } ') - ->assertJsonCount(3, 'data.users.0.tasksWith') - ->assertJsonCount(2, 'data.users.0.tasksWithout') - ->assertJsonCount(2, 'data.users.0.tasksSimple'); + ->assertJsonCount(3, 'data.users.0.tasksWith') + ->assertJsonCount(2, 'data.users.0.tasksWithout') + ->assertJsonCount(2, 'data.users.0.tasksSimple'); $this ->graphQL(/** @lang GraphQL */ ' @@ -377,9 +377,9 @@ public function testNested(): void } } ') - ->assertJsonCount(3, 'data.usersPaginated.data.0.tasksWith') - ->assertJsonCount(2, 'data.usersPaginated.data.0.tasksWithout') - ->assertJsonCount(2, 'data.usersPaginated.data.0.tasksSimple'); + ->assertJsonCount(3, 'data.usersPaginated.data.0.tasksWith') + ->assertJsonCount(2, 'data.usersPaginated.data.0.tasksWithout') + ->assertJsonCount(2, 'data.usersPaginated.data.0.tasksSimple'); $this ->graphQL(/** @lang GraphQL */ ' @@ -397,9 +397,9 @@ public function testNested(): void } } ') - ->assertJsonCount(3, 'data.user.tasksWith') - ->assertJsonCount(2, 'data.user.tasksWithout') - ->assertJsonCount(2, 'data.user.tasksSimple'); + ->assertJsonCount(3, 'data.user.tasksWith') + ->assertJsonCount(2, 'data.user.tasksWithout') + ->assertJsonCount(2, 'data.user.tasksSimple'); } public function testThrowsIfModelDoesNotSupportSoftDeletesTrashed(): void diff --git a/tests/Unit/Subscriptions/Iterators/AuthenticatingSyncIteratorTest.php b/tests/Unit/Subscriptions/Iterators/AuthenticatingSyncIteratorTest.php index d8584e5802..2a9665006d 100644 --- a/tests/Unit/Subscriptions/Iterators/AuthenticatingSyncIteratorTest.php +++ b/tests/Unit/Subscriptions/Iterators/AuthenticatingSyncIteratorTest.php @@ -79,7 +79,9 @@ static function (Subscriber $subscriber) use (&$processedItems, &$authenticatedU final class AuthenticatingSyncIteratorAuthenticatableStub implements Authenticatable { - public function __construct(private int $id) {} + public function __construct( + private int $id, + ) {} public function getAuthIdentifierName() { diff --git a/tests/Utils/Exceptions/ClientAwareException.php b/tests/Utils/Exceptions/ClientAwareException.php index 567317e73b..1369a677a1 100644 --- a/tests/Utils/Exceptions/ClientAwareException.php +++ b/tests/Utils/Exceptions/ClientAwareException.php @@ -1,6 +1,4 @@ -where(static fn (self $builder): \Tests\Utils\Models\User\UserBuilder => $builder - ->whereHas('company', static fn (EloquentBuilder $q): EloquentBuilder => $q - ->where('name', $args['company']))); + return $this->where( + static fn (self $builder): UserBuilder => $builder + ->whereHas('company', static fn (EloquentBuilder $q): EloquentBuilder => $q + ->where('name', $args['company'])), + ); } public function named(): self diff --git a/tests/Utils/Unions/Person.php b/tests/Utils/Unions/Person.php index 6d0bd39df2..3f128db2ce 100644 --- a/tests/Utils/Unions/Person.php +++ b/tests/Utils/Unions/Person.php @@ -7,7 +7,9 @@ final class Person { - public function __construct(private TypeRegistry $typeRegistry) {} + public function __construct( + private TypeRegistry $typeRegistry, + ) {} /** @param array $value */ public function resolveType(array $value): Type