Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Executor/ReferenceExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,8 @@ private function resolveField(ObjectType $parentType, $rootValue, $fieldNodes, $
// The resolve function's optional 4th argument is a collection of
// information about the current execution state.
$info = new ResolveInfo(
$fieldName,
$fieldDef,
$fieldNodes,
$returnType,
$parentType,
$path,
$exeContext->schema,
Expand Down
3 changes: 1 addition & 2 deletions src/Experimental/Executor/CoroutineExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,8 @@ private function spawn(CoroutineContext $ctx)
$returnType = $fieldDefinition->getType();

$ctx->resolveInfo = new ResolveInfo(
$ctx->shared->fieldName,
$fieldDefinition,
$ctx->shared->fieldNodes,
$returnType,
$ctx->type,
$ctx->path,
$this->schema,
Expand Down
55 changes: 31 additions & 24 deletions src/Type/Definition/ResolveInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@
class ResolveInfo
{
/**
* The name of the field being resolved.
* The definition of the field being resolved.
*
* @api
* @var string
* @var FieldDefinition
*/
public $fieldName;
public $fieldDefinition;

/**
* AST of all nodes referencing this field in the query.
* The name of the field being resolved.
*
* @api
* @var FieldNode[]
* @var string
*/
public $fieldNodes = [];
public $fieldName;

/**
* Expected return type of the field being resolved.
Expand All @@ -44,6 +44,14 @@ class ResolveInfo
*/
public $returnType;

/**
* AST of all nodes referencing this field in the query.
*
* @api
* @var FieldNode[]
*/
public $fieldNodes = [];

/**
* Parent type of the field being resolved.
*
Expand Down Expand Up @@ -104,17 +112,15 @@ class ResolveInfo
private $queryPlan;

/**
* @param FieldNode[] $fieldNodes
* @param ScalarType|ObjectType|InterfaceType|UnionType|EnumType|ListOfType|NonNull $returnType
* @param string[][] $path
* @param FragmentDefinitionNode[] $fragments
* @param mixed|null $rootValue
* @param mixed[] $variableValues
* @param FieldNode[] $fieldNodes
* @param string[][] $path
* @param FragmentDefinitionNode[] $fragments
* @param mixed|null $rootValue
* @param mixed[] $variableValues
*/
public function __construct(
string $fieldName,
FieldDefinition $fieldDefinition,
iterable $fieldNodes,
$returnType,
ObjectType $parentType,
array $path,
Schema $schema,
Expand All @@ -123,16 +129,17 @@ public function __construct(
?OperationDefinitionNode $operation,
array $variableValues
) {
$this->fieldName = $fieldName;
$this->fieldNodes = $fieldNodes;
$this->returnType = $returnType;
$this->parentType = $parentType;
$this->path = $path;
$this->schema = $schema;
$this->fragments = $fragments;
$this->rootValue = $rootValue;
$this->operation = $operation;
$this->variableValues = $variableValues;
$this->fieldDefinition = $fieldDefinition;
$this->fieldName = $fieldDefinition->name;
$this->returnType = $fieldDefinition->getType();
$this->fieldNodes = $fieldNodes;
$this->parentType = $parentType;
$this->path = $path;
$this->schema = $schema;
$this->fragments = $fragments;
$this->rootValue = $rootValue;
$this->operation = $operation;
$this->variableValues = $variableValues;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/Executor/ExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use GraphQL\Tests\Executor\TestClasses\NotSpecial;
use GraphQL\Tests\Executor\TestClasses\Special;
use GraphQL\Type\Definition\EnumType;
use GraphQL\Type\Definition\FieldDefinition;
use GraphQL\Type\Definition\InputObjectType;
use GraphQL\Type\Definition\InterfaceType;
use GraphQL\Type\Definition\ObjectType;
Expand Down Expand Up @@ -295,6 +296,7 @@ public function testProvidesInfoAboutCurrentExecutionState() : void
self::assertSame($rootValue, $info->rootValue);
self::assertEquals($ast->definitions[0], $info->operation);
self::assertEquals(['var' => '123'], $info->variableValues);
self::assertInstanceOf(FieldDefinition::class, $info->fieldDefinition);
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/Type/ResolveInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace GraphQL\Tests\Type;

use GraphQL\GraphQL;
use GraphQL\Type\Definition\FieldDefinition;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\ResolveInfo;
use GraphQL\Type\Definition\Type;
Expand Down