Automattic\WooCommerce\Vendor\GraphQL\Executor
ReferenceExecutor::executeOperation
Implements the "Evaluating operations" section of the spec.
Method of the class: ReferenceExecutor{}
No Hooks.
Returns
Array
Usage
// protected - for code of main (parent) or child class $result = $this->executeOperation( $operation, $rootValue );
- $operation(OperationDefinitionNode) (required)
- .
- $rootValue(mixed) (required)
- .
ReferenceExecutor::executeOperation() ReferenceExecutor::executeOperation code WC 10.9.1
protected function executeOperation(OperationDefinitionNode $operation, $rootValue)
{
$type = $this->getOperationRootType($this->exeContext->schema, $operation);
$fields = $this->collectFields($type, $operation->selectionSet, new \ArrayObject(), new \ArrayObject());
$path = [];
$unaliasedPath = [];
// Errors from sub-fields of a NonNull type may propagate to the top level,
// at which point we still log the error and null the parent field, which
// in this case is the entire response.
//
// Similar to completeValueCatchingError.
try {
$result = $operation->operation === 'mutation'
? $this->executeFieldsSerially($type, $rootValue, $path, $unaliasedPath, $fields, $this->exeContext->contextValue)
: $this->executeFields($type, $rootValue, $path, $unaliasedPath, $fields, $this->exeContext->contextValue);
$promise = $this->getPromise($result);
if ($promise !== null) {
return $promise->then(null, [$this, 'onError']);
}
return $result;
} catch (Error $error) {
$this->exeContext->addError($error);
return null;
}
}