GraphQL\Executor\Executor::resolveField PHP Method

resolveField() private static method

Resolves the field on the given source object. In particular, this figures out the value that the field returns by calling its resolve function, then calls completeValue to complete promises, serialize scalars, or execute the sub-selection-set for objects.
private static resolveField ( ExecutionContext $exeContext, ObjectType $parentType, $source, $fieldNodes, $path ) : array | Exception | mixed | null
$exeContext ExecutionContext
$parentType GraphQL\Type\Definition\ObjectType
$source
$fieldNodes
$path
return array | Exception | mixed | null
    private static function resolveField(ExecutionContext $exeContext, ObjectType $parentType, $source, $fieldNodes, $path)
    {
        $fieldNode = $fieldNodes[0];
        $fieldName = $fieldNode->name->value;
        $fieldDef = self::getFieldDef($exeContext->schema, $parentType, $fieldName);
        if (!$fieldDef) {
            return self::$UNDEFINED;
        }
        $returnType = $fieldDef->getType();
        // The resolve function's optional third argument is a collection of
        // information about the current execution state.
        $info = new ResolveInfo(['fieldName' => $fieldName, 'fieldNodes' => $fieldNodes, 'returnType' => $returnType, 'parentType' => $parentType, 'path' => $path, 'schema' => $exeContext->schema, 'fragments' => $exeContext->fragments, 'rootValue' => $exeContext->rootValue, 'operation' => $exeContext->operation, 'variableValues' => $exeContext->variableValues]);
        if (isset($fieldDef->resolveFn)) {
            $resolveFn = $fieldDef->resolveFn;
        } else {
            if (isset($parentType->resolveFieldFn)) {
                $resolveFn = $parentType->resolveFieldFn;
            } else {
                $resolveFn = self::$defaultFieldResolver;
            }
        }
        // The resolve function's optional third argument is a context value that
        // is provided to every resolve function within an execution. It is commonly
        // used to represent an authenticated user, or request-specific caches.
        $context = $exeContext->contextValue;
        // Get the resolve function, regardless of if its result is normal
        // or abrupt (error).
        $result = self::resolveOrError($exeContext, $fieldDef, $fieldNode, $resolveFn, $source, $context, $info);
        $result = self::completeValueCatchingError($exeContext, $returnType, $fieldNodes, $info, $path, $result);
        return $result;
    }