Executor
in package
Implements the "Evaluating requests" section of the GraphQL specification.
Table of Contents
- $defaultFieldResolver : callable
- $defaultPromiseAdapter : PromiseAdapter
- $implementationFactory : callable
- defaultFieldResolver() : mixed|null
- If a resolve function is not given, then a default resolve behavior is used which takes the property of the root value 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.
- execute() : ExecutionResult|Promise
- Executes DocumentNode against given $schema.
- getDefaultFieldResolver() : callable
- getImplementationFactory() : callable
- getPromiseAdapter() : PromiseAdapter
- promiseToExecute() : Promise
- Same as execute(), but requires promise adapter and returns a promise which is always fulfilled with an instance of ExecutionResult and never rejected.
- setDefaultFieldResolver() : mixed
- Set a custom default resolve function.
- setImplementationFactory() : mixed
- Set a custom executor implementation factory.
- setPromiseAdapter() : mixed
- Set a custom default promise adapter.
Properties
$defaultFieldResolver
private
static callable
$defaultFieldResolver
= [self::class, 'defaultFieldResolver']
$defaultPromiseAdapter
private
static PromiseAdapter
$defaultPromiseAdapter
$implementationFactory
private
static callable
$implementationFactory
= [\GraphQL\Executor\ReferenceExecutor::class, 'create']
Methods
defaultFieldResolver()
If a resolve function is not given, then a default resolve behavior is used which takes the property of the root value 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(mixed $objectValue, array<string, mixed> $args, mixed|null $contextValue, ResolveInfo $info) : mixed|null
Parameters
- $objectValue : mixed
- $args : array<string, mixed>
- $contextValue : mixed|null
- $info : ResolveInfo
Return values
mixed|null —execute()
Executes DocumentNode against given $schema.
public
static execute(Schema $schema, DocumentNode $documentNode[, mixed|null $rootValue = null ][, mixed|null $contextValue = null ][, array<string|int, mixed>|ArrayAccess|null $variableValues = null ][, string|null $operationName = null ][, callable|null $fieldResolver = null ]) : ExecutionResult|Promise
Always returns ExecutionResult and never throws.
All errors which occur during operation execution are collected in $result->errors
.
Parameters
- $schema : Schema
- $documentNode : DocumentNode
- $rootValue : mixed|null = null
- $contextValue : mixed|null = null
- $variableValues : array<string|int, mixed>|ArrayAccess|null = null
- $operationName : string|null = null
- $fieldResolver : callable|null = null
Return values
ExecutionResult|Promise —getDefaultFieldResolver()
public
static getDefaultFieldResolver() : callable
Return values
callable —getImplementationFactory()
public
static getImplementationFactory() : callable
Return values
callable —getPromiseAdapter()
public
static getPromiseAdapter() : PromiseAdapter
Return values
PromiseAdapter —promiseToExecute()
Same as execute(), but requires promise adapter and returns a promise which is always fulfilled with an instance of ExecutionResult and never rejected.
public
static promiseToExecute(PromiseAdapter $promiseAdapter, Schema $schema, DocumentNode $documentNode[, mixed|null $rootValue = null ][, mixed|null $contextValue = null ][, array<string|int, mixed>|null $variableValues = null ][, string|null $operationName = null ][, callable|null $fieldResolver = null ]) : Promise
Useful for async PHP platforms.
Parameters
- $promiseAdapter : PromiseAdapter
- $schema : Schema
- $documentNode : DocumentNode
- $rootValue : mixed|null = null
- $contextValue : mixed|null = null
- $variableValues : array<string|int, mixed>|null = null
- $operationName : string|null = null
- $fieldResolver : callable|null = null
Return values
Promise —setDefaultFieldResolver()
Set a custom default resolve function.
public
static setDefaultFieldResolver(callable $fieldResolver) : mixed
Parameters
- $fieldResolver : callable
Return values
mixed —setImplementationFactory()
Set a custom executor implementation factory.
public
static setImplementationFactory(callable $implementationFactory) : mixed
Parameters
- $implementationFactory : callable
Return values
mixed —setPromiseAdapter()
Set a custom default promise adapter.
public
static setPromiseAdapter([PromiseAdapter|null $defaultPromiseAdapter = null ]) : mixed
Parameters
- $defaultPromiseAdapter : PromiseAdapter|null = null