src/Executor/Executor.php
protected static function resolveFieldOrError(ExecutionContext $context, ObjectType $parent, $source, $asts, FieldDefinition $definition)
    {
        $ast = $asts[0];
        $type = $definition->getType();
        $resolver = $definition->getResolveCallback() ?: [__CLASS__, 'defaultResolveFn'];
        $data = $definition->getResolveData();
        $args = Values::getArgumentValues($definition->getArguments(), $ast->get('arguments'), $context->variables);

        try {
            // @todo Change the resolver function syntax to use a value object.
            $result = call_user_func($resolver, $source, $args, $context->root, $ast, $type, $parent, $context->schema, $data);
        } catch (\Exception $error) {
            throw $error;
        }

        return self::completeField($context, $type, $asts, $result);
    }
protected static function resolveFieldOrError(ExecutionContext $context, ObjectType $parent, $source, $asts, FieldDefinition $definition)
    {
        $ast = $asts[0];
        $type = $definition->getType();
        $resolver = $definition->getResolveCallback() ?: [__CLASS__, 'defaultResolveFn'];
        $data = $definition->getResolveData();
        $args = Values::getArgumentValues($definition->getArguments(), $ast->get('arguments'), $context->variables);

        try {
            // @todo Change the resolver function syntax to use a value object.
            $result = call_user_func($resolver, $source, $args, $context->root, $ast, $type, $parent, $context->schema, $data);
        } catch (\Exception $error) {
            throw $error;
        }

        return self::completeField($context, $type, $asts, $result);
    }
protected static function resolveFieldOrError ( ExecutionContext $ context , ObjectType $ parent , $ source , $ asts , FieldDefinition $ definition ) { $ ast = $ asts [ 0 ] ; $ type = $ definition -> getType ( ) ; $ resolver = $ definition -> getResolveCallback ( ) ? : [ __CLASS__ , 'defaultResolveFn' ] ; $ data = $ definition -> getResolveData ( ) ; $ args = Values :: getArgumentValues ( $ definition -> getArguments ( ) , $ ast -> get ( 'arguments' ) , $ context -> variables ) ; try { // @todo Change the resolver function syntax to use a value object. $ result = call_user_func ( $ resolver , $ source , $ args , $ context -> root , $ ast , $ type , $ parent , $ context -> schema , $ data ) ; } catch ( \ Exception $ error ) { throw $ error ; } return self :: completeField ( $ context , $ type , $ asts , $ result ) ; }
Resolves the field on the given source object.

In particular, this figures out the object that the field returns using
the resolve function, then calls completeField to coerce scalars or
execute the sub selection set for objects.

@param ExecutionContext $context
@param ObjectType $parent
@param $source
@param $asts
@param FieldDefinition $definition

@return array|mixed|null|string

@throws \Exception
Resolves the field on the given source object .