From 91b72f145d0e91eaaff4e1d7fd8c264d2eb51cf2 Mon Sep 17 00:00:00 2001 From: spawnia Date: Sun, 23 Jun 2019 18:25:02 +0200 Subject: [PATCH] Context is the 3rd, ResolveInfo the 4th resolver argument --- docs/reference.md | 2 +- src/Executor/ReferenceExecutor.php | 10 +++++----- src/Type/Definition/ResolveInfo.php | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/reference.md b/docs/reference.md index 7ea7709..f2d828e 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -299,7 +299,7 @@ static function getNullableType($type) ``` # GraphQL\Type\Definition\ResolveInfo Structure containing information useful for field resolution process. -Passed as 3rd argument to every field resolver. See [docs on field resolving (data fetching)](data-fetching.md). +Passed as 4th argument to every field resolver. See [docs on field resolving (data fetching)](data-fetching.md). **Class Props:** ```php diff --git a/src/Executor/ReferenceExecutor.php b/src/Executor/ReferenceExecutor.php index 6e35f7c..91009cf 100644 --- a/src/Executor/ReferenceExecutor.php +++ b/src/Executor/ReferenceExecutor.php @@ -526,7 +526,11 @@ class ReferenceExecutor implements ExecutorImplementation return self::$UNDEFINED; } $returnType = $fieldDef->getType(); - // The resolve function's optional third argument is a collection of + // The resolve function's optional 3rd argument is a context value that + // is provided to every resolve function within an execution. It is commonly + // used to represent an authenticated user, or request-specific caches. + $context = $exeContext->contextValue; + // The resolve function's optional 4th argument is a collection of // information about the current execution state. $info = new ResolveInfo( $fieldName, @@ -547,10 +551,6 @@ class ReferenceExecutor implements ExecutorImplementation } else { $resolveFn = $this->exeContext->fieldResolver; } - // The resolve function's optional third argument is a context value that - // is provided to every resolve function within an execution. It is commonly - // used to represent an authenticated user, or request-specific caches. - $context = $exeContext->contextValue; // Get the resolve function, regardless of if its result is normal // or abrupt (error). $result = $this->resolveOrError( diff --git a/src/Type/Definition/ResolveInfo.php b/src/Type/Definition/ResolveInfo.php index f2525de..7684e93 100644 --- a/src/Type/Definition/ResolveInfo.php +++ b/src/Type/Definition/ResolveInfo.php @@ -15,7 +15,8 @@ use function array_merge_recursive; /** * Structure containing information useful for field resolution process. - * Passed as 3rd argument to every field resolver. See [docs on field resolving (data fetching)](data-fetching.md). + * + * Passed as 4th argument to every field resolver. See [docs on field resolving (data fetching)](data-fetching.md). */ class ResolveInfo {