Automattic\WooCommerce\Vendor\GraphQL\Executor
ReferenceExecutor::executeFields
Implements the "Evaluating selection sets" section of the spec for "read" mode.
Method of the class: ReferenceExecutor{}
No Hooks.
Returns
Promise|\stdClass|Array
Usage
// protected - for code of main (parent) or child class $result = $this->executeFields( $parentType, $rootValue, $path, $unaliasedPath, $fields, $contextValue );
- $parentType(ObjectType) (required)
- .
- $rootValue(mixed) (required)
- .
- $path(list<string|int>) (required)
- .
- $unaliasedPath(list<string|int>) (required)
- .
- $fields(ArrayObject) (required)
- .
- $contextValue(mixed) (required)
- .
ReferenceExecutor::executeFields() ReferenceExecutor::executeFields code WC 10.9.1
protected function executeFields(ObjectType $parentType, $rootValue, array $path, array $unaliasedPath, \ArrayObject $fields, $contextValue)
{
$containsPromise = false;
$results = [];
foreach ($fields as $responseName => $fieldNodes) {
$result = $this->resolveField(
$parentType,
$rootValue,
$fieldNodes,
$responseName,
$path,
$unaliasedPath,
$this->maybeScopeContext($contextValue)
);
if ($result === static::$UNDEFINED) {
continue;
}
if (! $containsPromise && $this->isPromise($result)) {
$containsPromise = true;
}
$results[$responseName] = $result;
}
// If there are no promises, we can just return the object
if (! $containsPromise) {
return static::fixResultsIfEmptyArray($results);
}
// Otherwise, results is a map from field name to the result of resolving that
// field, which is possibly a promise. Return a promise that will return this
// same map, but with any promises replaced with the values they resolved to.
return $this->promiseForAssocArray($results);
}