Automattic\WooCommerce\Vendor\GraphQL
GraphQL::executeQuery
Executes graphql query.
More sophisticated Automattic\WooCommerce\Vendor\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 Automattic\WooCommerce\Vendor\GraphQL type system to use when validating and executing a query.
source:
A Automattic\WooCommerce\Vendor\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. If the passed object implements the `ScopedContext` interface, its `clone()` method will be called before passing the context down to a field. This allows passing information to child fields in the query tree without affecting sibling or parent fields.
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)
Method of the class: GraphQL{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = GraphQL::executeQuery( $schema, $source, $rootValue, $contextValue, ?array $variableValues, ?string $operationName, ?callable $fieldResolver, ?array $validationRules ): ExecutionResult;
- $schema(SchemaType) (required)
- .
- $source(string|DocumentNode) (required)
- .
- $rootValue(mixed)
- .
Default:null - $contextValue(mixed)
- .
Default:null - ?array $variableValues
- .
Default:null - ?string $operationName
- .
Default:null - ?callable $fieldResolver
- .
Default:null - ?array $validationRules
- .
Default:null
GraphQL::executeQuery() GraphQL::executeQuery code WC 11.1.2
public static function executeQuery(
SchemaType $schema,
$source,
$rootValue = null,
$contextValue = null,
?array $variableValues = null,
?string $operationName = null,
?callable $fieldResolver = null,
?array $validationRules = null
): ExecutionResult {
$promiseAdapter = new SyncPromiseAdapter();
$promise = self::promiseToExecute(
$promiseAdapter,
$schema,
$source,
$rootValue,
$contextValue,
$variableValues,
$operationName,
$fieldResolver,
$validationRules
);
return $promiseAdapter->wait($promise);
}