GraphQL\Executor\Executor::defaultFieldResolver PHP Method

defaultFieldResolver() public static method

If a resolve function is not given, then a default resolve behavior is used which takes the property of the source object of the same name as the field and returns it as the result, or if it's a function, returns the result of calling that function while passing along args and context.
public static defaultFieldResolver ( $source, $args, $context, ResolveInfo $info ) : mixed | null
$source
$args
$context
$info GraphQL\Type\Definition\ResolveInfo
return mixed | null
    public static function defaultFieldResolver($source, $args, $context, ResolveInfo $info)
    {
        $fieldName = $info->fieldName;
        $property = null;
        if (is_array($source) || $source instanceof \ArrayAccess) {
            if (isset($source[$fieldName])) {
                $property = $source[$fieldName];
            }
        } else {
            if (is_object($source)) {
                if (isset($source->{$fieldName})) {
                    $property = $source->{$fieldName};
                }
            }
        }
        return $property instanceof \Closure ? $property($source, $args, $context) : $property;
    }