Documentation

ResolveInfo
in package

Structure containing information useful for field resolution process.

Passed as 4th argument to every field resolver. See docs on field resolving (data fetching).

Table of Contents

$fieldDefinition  : FieldDefinition
The definition of the field being resolved.
$fieldName  : string
The name of the field being resolved.
$fieldNodes  : array<string|int, FieldNode>
AST of all nodes referencing this field in the query.
$fragments  : array<string|int, FragmentDefinitionNode>
AST of all fragments defined in query.
$operation  : OperationDefinitionNode|null
AST of operation definition node (query, mutation).
$parentType  : ObjectType
Parent type of the field being resolved.
$path  : array<string|int, string>
Path to this field from the very root value.
$returnType  : Type
Expected return type of the field being resolved.
$rootValue  : mixed
Root value passed to query execution.
$schema  : Schema
Instance of a schema used for execution.
$variableValues  : array<string|int, mixed>
Array of variables passed to query execution.
$queryPlan  : QueryPlan
Lazily initialized.
__construct()  : mixed
getFieldSelection()  : array<string, mixed>
Helper method that returns names of all fields selected in query for $this->fieldName up to $depth levels.
lookAhead()  : QueryPlan
foldSelectionSet()  : array<string|int, bool>

Properties

$fieldDefinition

The definition of the field being resolved.

public FieldDefinition $fieldDefinition

$fieldName

The name of the field being resolved.

public string $fieldName

$fieldNodes

AST of all nodes referencing this field in the query.

public array<string|int, FieldNode> $fieldNodes = []

$path

Path to this field from the very root value.

public array<string|int, string> $path

$returnType

Expected return type of the field being resolved.

public Type $returnType

$rootValue

Root value passed to query execution.

public mixed $rootValue

$schema

Instance of a schema used for execution.

public Schema $schema

$variableValues

Array of variables passed to query execution.

public array<string|int, mixed> $variableValues = []

Methods

__construct()

public __construct(FieldDefinition $fieldDefinition, array<string|int, FieldNode$fieldNodes, ObjectType $parentType, array<string|int, string> $path, Schema $schema, array<string|int, FragmentDefinitionNode$fragments, mixed|null $rootValue, OperationDefinitionNode|null $operation, array<string|int, mixed> $variableValues) : mixed
Parameters
$fieldDefinition : FieldDefinition
$fieldNodes : array<string|int, FieldNode>
$parentType : ObjectType
$path : array<string|int, string>
$schema : Schema
$fragments : array<string|int, FragmentDefinitionNode>
$rootValue : mixed|null
$operation : OperationDefinitionNode|null
$variableValues : array<string|int, mixed>
Return values
mixed

getFieldSelection()

Helper method that returns names of all fields selected in query for $this->fieldName up to $depth levels.

public getFieldSelection(int $depth) : array<string, mixed>

Example: query MyQuery{ { root { id, nested { nested1 nested2 { nested3 } } } }

Given this ResolveInfo instance is a part of "root" field resolution, and $depth === 1, method will return: [ 'id' => true, 'nested' => [ nested1 => true, nested2 => true ] ]

Warning: this method it is a naive implementation which does not take into account conditional typed fragments. So use it with care for fields of interface and union types.

Parameters
$depth : int

How many levels to include in output

Return values
array<string, mixed>

lookAhead()

public lookAhead([array<string|int, mixed> $options = [] ]) : QueryPlan
Parameters
$options : array<string|int, mixed> = []
Return values
QueryPlan

foldSelectionSet()

private foldSelectionSet(SelectionSetNode $selectionSet, int $descend) : array<string|int, bool>
Parameters
$selectionSet : SelectionSetNode
$descend : int
Return values
array<string|int, bool>

Search results