PHP Class GraphQL\Executor\Executor

"Definitions" are the generic name for top-level statements in the document. Examples of this include: 1) Operations (such as a query) 2) Fragments "Operations" are a generic name for requests in the document. Examples of this include: 1) query, 2) mutation "Selections" are the statements that can appear legally and at single level of the query. These include: 1) field references e.g "a" 2) fragment "spreads" e.g. "...c" 3) inline fragment "spreads" e.g. "...on Type { a }"
Mostrar archivo Open project: webonyx/graphql-php Class Usage Examples

Public Methods

Method Description
completeValueWithLocatedError ( ExecutionContext $exeContext, Type $returnType, $fieldNodes, ResolveInfo $info, $path, $result ) : array | null | GraphQL\Executor\Promise\Promise This is a small wrapper around completeValue which annotates errors with location information.
defaultFieldResolver ( $source, $args, $context, ResolveInfo $info ) : mixed | null If a resolve function is not given, then a default resolve behavior is used which takes the property of the source object of the same name as the field and returns it as the result, or if it's a function, returns the result of calling that function while passing along args and context.
defaultResolveFn ( $source, $args, $context, ResolveInfo $info ) : mixed | null
execute ( Schema $schema, DocumentNode $ast, $rootValue = null, $contextValue = null, array | ArrayAccess $variableValues = null, null $operationName = null ) : ExecutionResult | GraphQL\Executor\Promise\Promise
setDefaultFieldResolver ( callable $fn ) Custom default resolve function
setDefaultResolveFn ( callable $fn )
setPromiseAdapter ( GraphQL\Executor\Promise\PromiseAdapter $promiseAdapter = null )

Private Methods

Method Description
buildExecutionContext ( Schema $schema, DocumentNode $documentNode, $rootValue, $contextValue, $rawVariableValues, string $operationName = null ) : ExecutionContext Constructs a ExecutionContext object from the arguments passed to execute, which we will pass throughout the other execution methods.
collectFields ( ExecutionContext $exeContext, ObjectType $runtimeType, SelectionSetNode $selectionSet, $fields, $visitedFragmentNames ) : ArrayObject Given a selectionSet, adds all of the fields in that selection to the passed in map of fields, and returns it at the end.
completeAbstractValue ( ExecutionContext $exeContext, GraphQL\Type\Definition\AbstractType $returnType, $fieldNodes, ResolveInfo $info, array $path, &$result ) : mixed Complete a value of an abstract type by determining the runtime object type of that value, then complete the value for that type.
completeLeafValue ( GraphQL\Type\Definition\LeafType $returnType, &$result ) : mixed Complete a Scalar or Enum by serializing to a valid value, returning null if serialization is not possible.
completeListValue ( ExecutionContext $exeContext, ListOfType $returnType, $fieldNodes, ResolveInfo $info, array $path, &$result ) : array | GraphQL\Executor\Promise\Promise Complete a list value by completing each item in the list with the inner type
completeObjectValue ( ExecutionContext $exeContext, ObjectType $returnType, $fieldNodes, ResolveInfo $info, array $path, &$result ) : array | GraphQL\Executor\Promise\Promise | stdClass Complete an Object value by executing all sub-selections.
completeValue ( ExecutionContext $exeContext, Type $returnType, FieldNode[] $fieldNodes, ResolveInfo $info, array $path, &$result ) : array | null | GraphQL\Executor\Promise\Promise Implements the instructions for completeValue as defined in the "Field entries" section of the spec.
completeValueCatchingError ( ExecutionContext $exeContext, Type $returnType, $fieldNodes, ResolveInfo $info, $path, $result ) : array | null | GraphQL\Executor\Promise\Promise This is a small wrapper around completeValue which detects and logs errors in the execution context.
doesFragmentConditionMatch ( ExecutionContext $exeContext, $fragment, ObjectType $type ) : boolean Determines if a fragment is applicable to the given type.
executeFields ( ExecutionContext $exeContext, ObjectType $parentType, $source, $path, $fields ) : GraphQL\Executor\Promise\Promise | stdClass | array Implements the "Evaluating selection sets" section of the spec for "read" mode.
executeFieldsSerially ( ExecutionContext $exeContext, ObjectType $parentType, $sourceValue, $path, $fields ) : GraphQL\Executor\Promise\Promise | stdClass | array Implements the "Evaluating selection sets" section of the spec for "write" mode.
executeOperation ( ExecutionContext $exeContext, OperationDefinitionNode $operation, $rootValue ) : GraphQL\Executor\Promise\Promise | stdClass | array Implements the "Evaluating operations" section of the spec.
fixResultsIfEmptyArray ( $results ) : stdClass | array
getFieldDef ( Schema $schema, ObjectType $parentType, $fieldName ) : FieldDefinition This method looks up the field on the given type defintion.
getFieldEntryKey ( FieldNode $node ) : string Implements the logic to compute the key of a given fields entry
getOperationRootType ( Schema $schema, OperationDefinitionNode $operation ) : ObjectType Extracts the root type of the operation from the schema.
inferTypeOf ( $value, $context, ResolveInfo $info, GraphQL\Type\Definition\AbstractType $abstractType ) : ObjectType | null Infer type of the value using isTypeOf of corresponding AbstractType
resolveField ( ExecutionContext $exeContext, ObjectType $parentType, $source, $fieldNodes, $path ) : array | Exception | mixed | null Resolves the field on the given source object. In particular, this figures out the value that the field returns by calling its resolve function, then calls completeValue to complete promises, serialize scalars, or execute the sub-selection-set for objects.
resolveOrError ( ExecutionContext $exeContext, FieldDefinition $fieldDef, FieldNode $fieldNode, callable $resolveFn, mixed $source, mixed $context, ResolveInfo $info ) : Exception | mixed Isolates the "ReturnOrAbrupt" behavior to not de-opt the resolveField function. Returns the result of resolveFn or the abrupt-return Error object.
shouldIncludeNode ( ExecutionContext $exeContext, $directives ) : boolean Determines if a field should be included based on the @include and @skip directives, where @skip has higher precedence than @include.

Method Details

completeValueWithLocatedError() public static method

This is a small wrapper around completeValue which annotates errors with location information.
public static completeValueWithLocatedError ( ExecutionContext $exeContext, Type $returnType, $fieldNodes, ResolveInfo $info, $path, $result ) : array | null | GraphQL\Executor\Promise\Promise
$exeContext ExecutionContext
$returnType GraphQL\Type\Definition\Type
$fieldNodes
$info GraphQL\Type\Definition\ResolveInfo
$path
$result
return array | null | GraphQL\Executor\Promise\Promise

defaultFieldResolver() public static method

If a resolve function is not given, then a default resolve behavior is used which takes the property of the source object of the same name as the field and returns it as the result, or if it's a function, returns the result of calling that function while passing along args and context.
public static defaultFieldResolver ( $source, $args, $context, ResolveInfo $info ) : mixed | null
$source
$args
$context
$info GraphQL\Type\Definition\ResolveInfo
return mixed | null

defaultResolveFn() public static method

Deprecation: as of v0.8.0 should use self::defaultFieldResolver method
public static defaultResolveFn ( $source, $args, $context, ResolveInfo $info ) : mixed | null
$source
$args
$context
$info GraphQL\Type\Definition\ResolveInfo
return mixed | null

execute() public static method

public static execute ( Schema $schema, DocumentNode $ast, $rootValue = null, $contextValue = null, array | ArrayAccess $variableValues = null, null $operationName = null ) : ExecutionResult | GraphQL\Executor\Promise\Promise
$schema GraphQL\Schema
$ast GraphQL\Language\AST\DocumentNode
$rootValue
$contextValue
$variableValues array | ArrayAccess
$operationName null
return ExecutionResult | GraphQL\Executor\Promise\Promise

setDefaultFieldResolver() public static method

Custom default resolve function
public static setDefaultFieldResolver ( callable $fn )
$fn callable

setDefaultResolveFn() public static method

Deprecation: as of v0.8.0 should use self::setDefaultFieldResolver method
public static setDefaultResolveFn ( callable $fn )
$fn callable

setPromiseAdapter() public static method

public static setPromiseAdapter ( GraphQL\Executor\Promise\PromiseAdapter $promiseAdapter = null )
$promiseAdapter GraphQL\Executor\Promise\PromiseAdapter