private static function completeObjectValue(ExecutionContext $exeContext, ObjectType $returnType, $fieldNodes, ResolveInfo $info, $path, &$result)
{
// If there is an isTypeOf predicate function, call it with the
// current result. If isTypeOf returns false, then raise an error rather
// than continuing execution.
if (false === $returnType->isTypeOf($result, $exeContext->contextValue, $info)) {
throw new Error("Expected value of type {$returnType} but got: " . Utils::getVariableType($result), $fieldNodes);
}
// Collect sub-fields to execute to complete this value.
$subFieldNodes = new \ArrayObject();
$visitedFragmentNames = new \ArrayObject();
foreach ($fieldNodes as $fieldNode) {
if (isset($fieldNode->selectionSet)) {
$subFieldNodes = self::collectFields($exeContext, $returnType, $fieldNode->selectionSet, $subFieldNodes, $visitedFragmentNames);
}
}
return self::executeFields($exeContext, $returnType, $result, $path, $subFieldNodes);
}