From 6991ddcda6c2f3187301bac56a29a43f5861df07 Mon Sep 17 00:00:00 2001 From: spawnia Date: Wed, 14 Dec 2022 14:55:53 +0100 Subject: [PATCH] Format and update docs --- CHANGELOG.md | 2 +- docs/5/custom-directives/field-directives.md | 2 +- docs/master/custom-directives/field-directives.md | 2 +- src/Execution/Arguments/ArgumentSet.php | 2 ++ src/Schema/Directives/AllDirective.php | 10 ++++++---- src/Schema/Directives/FindDirective.php | 10 ++++++---- src/Schema/Directives/FirstDirective.php | 10 ++++++---- 7 files changed, 23 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54a78d9b82..f2da8efe23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ You can find and compare releases at the [GitHub release page](https://github.co ### Fixed -- Create a new `ResolveInfo` class to extend with `$argumentSet` in response to PHP 8.2 deprecating dynamic properties +- Wrap base `ResolveInfo` class and extend it with `public ArgumentSet $argumentSet` in response to PHP 8.2 deprecating dynamic properties ## v5.69.0 diff --git a/docs/5/custom-directives/field-directives.md b/docs/5/custom-directives/field-directives.md index cf4fd4f7d6..63cbcba4dd 100644 --- a/docs/5/custom-directives/field-directives.md +++ b/docs/5/custom-directives/field-directives.md @@ -77,7 +77,7 @@ type Query { A [`\Nuwave\Lighthouse\Support\Contracts\FieldBuilderDirective`](https://github.com/nuwave/lighthouse/blob/master/src/Support/Contracts/FieldBuilderDirective.php) directive allows modifying the database query that Lighthouse creates for a field. -> This directive only works if the field resolver passes its builder through a call to `$resolveInfo->argumentSet->enhanceBuilder()`. +> This directive only works if the field resolver passes its builder through a call to `$resolveInfo->enhanceBuilder()`. > Built-in field resolver directives that query the database do this, such as [@all](../api-reference/directives.md#all) or [@hasMany](../api-reference/directives.md#hasmany). The following directives use the defined filter for resolving the query: diff --git a/docs/master/custom-directives/field-directives.md b/docs/master/custom-directives/field-directives.md index cf4fd4f7d6..63cbcba4dd 100644 --- a/docs/master/custom-directives/field-directives.md +++ b/docs/master/custom-directives/field-directives.md @@ -77,7 +77,7 @@ type Query { A [`\Nuwave\Lighthouse\Support\Contracts\FieldBuilderDirective`](https://github.com/nuwave/lighthouse/blob/master/src/Support/Contracts/FieldBuilderDirective.php) directive allows modifying the database query that Lighthouse creates for a field. -> This directive only works if the field resolver passes its builder through a call to `$resolveInfo->argumentSet->enhanceBuilder()`. +> This directive only works if the field resolver passes its builder through a call to `$resolveInfo->enhanceBuilder()`. > Built-in field resolver directives that query the database do this, such as [@all](../api-reference/directives.md#all) or [@hasMany](../api-reference/directives.md#hasmany). The following directives use the defined filter for resolving the query: diff --git a/src/Execution/Arguments/ArgumentSet.php b/src/Execution/Arguments/ArgumentSet.php index a8a978ace6..4e321c0cee 100644 --- a/src/Execution/Arguments/ArgumentSet.php +++ b/src/Execution/Arguments/ArgumentSet.php @@ -78,6 +78,8 @@ public function has(string $key): bool * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Relations\Relation|\Laravel\Scout\Builder * * @phpstan-return TBuilder + * + * @deprecated will be moved to \Nuwave\Lighthouse\Execution\ResolveInfo */ public function enhanceBuilder(object $builder, array $scopes, \Closure $directiveFilter = null): object { diff --git a/src/Schema/Directives/AllDirective.php b/src/Schema/Directives/AllDirective.php index 7654eec010..92e8958764 100644 --- a/src/Schema/Directives/AllDirective.php +++ b/src/Schema/Directives/AllDirective.php @@ -63,10 +63,12 @@ public function resolveField(FieldValue $fieldValue): FieldValue $query = $this->getModelClass()::query(); } - return $resolveInfo->enhanceBuilder( - $query, - $this->directiveArgValue('scopes', []) - )->get(); + return $resolveInfo + ->enhanceBuilder( + $query, + $this->directiveArgValue('scopes', []) + ) + ->get(); }); return $fieldValue; diff --git a/src/Schema/Directives/FindDirective.php b/src/Schema/Directives/FindDirective.php index 5652a48887..fcd2f8860e 100644 --- a/src/Schema/Directives/FindDirective.php +++ b/src/Schema/Directives/FindDirective.php @@ -35,10 +35,12 @@ public static function definition(): string public function resolveField(FieldValue $fieldValue): FieldValue { $fieldValue->setResolver(function ($root, array $args, GraphQLContext $context, ResolveInfo $resolveInfo): ?Model { - $results = $resolveInfo->enhanceBuilder( - $this->getModelClass()::query(), - $this->directiveArgValue('scopes', []) - )->get(); + $results = $resolveInfo + ->enhanceBuilder( + $this->getModelClass()::query(), + $this->directiveArgValue('scopes', []) + ) + ->get(); if ($results->count() > 1) { throw new Error('The query returned more than one result.'); diff --git a/src/Schema/Directives/FirstDirective.php b/src/Schema/Directives/FirstDirective.php index a9841f8f2a..45f6b0850c 100644 --- a/src/Schema/Directives/FirstDirective.php +++ b/src/Schema/Directives/FirstDirective.php @@ -34,10 +34,12 @@ public static function definition(): string public function resolveField(FieldValue $fieldValue): FieldValue { $fieldValue->setResolver(function ($root, array $args, GraphQLContext $context, ResolveInfo $resolveInfo): ?Model { - return $resolveInfo->enhanceBuilder( - $this->getModelClass()::query(), - $this->directiveArgValue('scopes', []) - )->first(); + return $resolveInfo + ->enhanceBuilder( + $this->getModelClass()::query(), + $this->directiveArgValue('scopes', []) + ) + ->first(); }); return $fieldValue;