GraphQL
in package
This is the primary facade for fulfilling GraphQL operations.
Table of Contents
- execute() : Promise|array<string|int, mixed>
- executeAndReturnResult() : ExecutionResult|Promise
- executeQuery() : ExecutionResult
- Executes graphql query.
- getInternalDirectives() : array<string|int, Directive>
- Returns directives defined in GraphQL spec
- getStandardDirectives() : array<string|int, Directive>
- Returns directives defined in GraphQL spec
- getStandardTypes() : array<string|int, Type>
- Returns types defined in GraphQL spec
- getStandardValidationRules() : array<string|int, ValidationRule>
- Returns standard validation rules implementing GraphQL spec
- overrideStandardTypes() : mixed
- Replaces standard types with types from this list (matching by name) Standard types not listed here remain untouched.
- promiseToExecute() : Promise
- Same as executeQuery(), but requires PromiseAdapter and always returns a Promise.
- setDefaultFieldResolver() : void
- Set default resolver implementation
- setPromiseAdapter() : void
- useExperimentalExecutor() : mixed
- Experimental: Switch to the new executor
- useReferenceExecutor() : mixed
- Experimental: Switch back to the default executor
Methods
execute()
public
static execute(Schema $schema, string|DocumentNode $source[, mixed $rootValue = null ][, mixed $contextValue = null ][, array<string|int, mixed>|null $variableValues = null ][, string|null $operationName = null ]) : Promise|array<string|int, mixed>
Parameters
- $schema : Schema
- $source : string|DocumentNode
- $rootValue : mixed = null
- $contextValue : mixed = null
- $variableValues : array<string|int, mixed>|null = null
- $operationName : string|null = null
Tags
Return values
Promise|array<string|int, mixed> —executeAndReturnResult()
public
static executeAndReturnResult(Schema $schema, string|DocumentNode $source[, mixed $rootValue = null ][, mixed $contextValue = null ][, array<string|int, mixed>|null $variableValues = null ][, string|null $operationName = null ]) : ExecutionResult|Promise
Parameters
- $schema : Schema
- $source : string|DocumentNode
- $rootValue : mixed = null
- $contextValue : mixed = null
- $variableValues : array<string|int, mixed>|null = null
- $operationName : string|null = null
Tags
Return values
ExecutionResult|Promise —executeQuery()
Executes graphql query.
public
static executeQuery(Schema $schema, string|DocumentNode $source[, mixed $rootValue = null ][, mixed $contextValue = null ][, array<string|int, mixed>|null $variableValues = null ][, string|null $operationName = null ][, callable|null $fieldResolver = null ][, array<string|int, ValidationRule> $validationRules = null ]) : ExecutionResult
More sophisticated GraphQL servers, such as those which persist queries, may wish to separate the validation and execution phases to a static time tooling step, and a server runtime step.
Available options:
schema: The GraphQL type system to use when validating and executing a query. source: A GraphQL language formatted string representing the requested operation. rootValue: The value provided as the first argument to resolver functions on the top level type (e.g. the query object type). contextValue: The context value is provided as an argument to resolver functions after field arguments. It is used to pass shared information useful at any point during executing this query, for example the currently logged in user and connections to databases or other services. variableValues: A mapping of variable name to runtime value to use for all variables defined in the requestString. operationName: The name of the operation to use if requestString contains multiple possible operations. Can be omitted if requestString contains only one operation. fieldResolver: A resolver function to use when one is not provided by the schema. If not provided, the default field resolver is used (which looks for a value on the source value with the field's name). validationRules: A set of rules for query validation step. Default value is all available rules. Empty array would allow to skip query validation (may be convenient for persisted queries which are validated before persisting and assumed valid during execution)
Parameters
- $schema : Schema
- $source : string|DocumentNode
- $rootValue : mixed = null
- $contextValue : mixed = null
- $variableValues : array<string|int, mixed>|null = null
- $operationName : string|null = null
- $fieldResolver : callable|null = null
- $validationRules : array<string|int, ValidationRule> = null
Return values
ExecutionResult —getInternalDirectives()
Returns directives defined in GraphQL spec
public
static getInternalDirectives() : array<string|int, Directive>
Tags
Return values
array<string|int, Directive> —getStandardDirectives()
Returns directives defined in GraphQL spec
public
static getStandardDirectives() : array<string|int, Directive>
Return values
array<string|int, Directive> —getStandardTypes()
Returns types defined in GraphQL spec
public
static getStandardTypes() : array<string|int, Type>
Return values
array<string|int, Type> —getStandardValidationRules()
Returns standard validation rules implementing GraphQL spec
public
static getStandardValidationRules() : array<string|int, ValidationRule>
Return values
array<string|int, ValidationRule> —overrideStandardTypes()
Replaces standard types with types from this list (matching by name) Standard types not listed here remain untouched.
public
static overrideStandardTypes(array<string, ScalarType> $types) : mixed
Parameters
- $types : array<string, ScalarType>
Return values
mixed —promiseToExecute()
Same as executeQuery(), but requires PromiseAdapter and always returns a Promise.
public
static promiseToExecute(PromiseAdapter $promiseAdapter, Schema $schema, string|DocumentNode $source[, mixed $rootValue = null ][, mixed $context = null ][, array<string|int, mixed>|null $variableValues = null ][, string|null $operationName = null ][, callable|null $fieldResolver = null ][, array<string|int, ValidationRule>|null $validationRules = null ]) : Promise
Useful for Async PHP platforms.
Parameters
- $promiseAdapter : PromiseAdapter
- $schema : Schema
- $source : string|DocumentNode
- $rootValue : mixed = null
- $context : mixed = null
- $variableValues : array<string|int, mixed>|null = null
- $operationName : string|null = null
- $fieldResolver : callable|null = null
- $validationRules : array<string|int, ValidationRule>|null = null
Return values
Promise —setDefaultFieldResolver()
Set default resolver implementation
public
static setDefaultFieldResolver(callable $fn) : void
Parameters
- $fn : callable
Return values
void —setPromiseAdapter()
public
static setPromiseAdapter([PromiseAdapter|null $promiseAdapter = null ]) : void
Parameters
- $promiseAdapter : PromiseAdapter|null = null
Return values
void —useExperimentalExecutor()
Experimental: Switch to the new executor
public
static useExperimentalExecutor() : mixed
Return values
mixed —useReferenceExecutor()
Experimental: Switch back to the default executor
public
static useReferenceExecutor() : mixed