src/Node/Node.php
public static function nodeDefinitions(callable $idFetcher, callable $typeResolver = null) {
        $nodeInterface = new InterfaceType([
            'name' => 'Node',
            'description' => 'An object with an ID',
            'fields' => [
                'id' => [
                    'type' => Type::nonNull(Type::id()),
                    'description' => 'The id of the object',
                ]
            ],
            'resolveType' => $typeResolver
        ]);

        $nodeField = [
            'name' => 'node',
            'description' => 'Fetches an object given its ID',
            'type' => $nodeInterface,
            'args' => [
                'id' => [
                    'type' => Type::nonNull(Type::id()),
                    'description' => 'The ID of an object'
                ]
            ],
            'resolve' => function ($obj, $args, $context, $info) use ($idFetcher) {
                return $idFetcher($args['id'], $context, $info);
            }
        ];

        return [
            'nodeInterface' => $nodeInterface,
            'nodeField' => $nodeField
        ];
    }
public static function nodeDefinitions(callable $idFetcher, callable $typeResolver = null) {
        $nodeInterface = new InterfaceType([
            'name' => 'Node',
            'description' => 'An object with an ID',
            'fields' => [
                'id' => [
                    'type' => Type::nonNull(Type::id()),
                    'description' => 'The id of the object',
                ]
            ],
            'resolveType' => $typeResolver
        ]);

        $nodeField = [
            'name' => 'node',
            'description' => 'Fetches an object given its ID',
            'type' => $nodeInterface,
            'args' => [
                'id' => [
                    'type' => Type::nonNull(Type::id()),
                    'description' => 'The ID of an object'
                ]
            ],
            'resolve' => function ($obj, $args, $context, $info) use ($idFetcher) {
                return $idFetcher($args['id'], $context, $info);
            }
        ];

        return [
            'nodeInterface' => $nodeInterface,
            'nodeField' => $nodeField
        ];
    }
public static function nodeDefinitions ( callable $ idFetcher , callable $ typeResolver = null ) { $ nodeInterface = new InterfaceType ( [ 'name' => 'Node' , 'description' => 'An object with an ID' , 'fields' => [ 'id' => [ 'type' => Type :: nonNull ( Type :: id ( ) ) , 'description' => 'The id of the object' , ] ] , 'resolveType' => $ typeResolver ] ) ; $ nodeField = [ 'name' => 'node' , 'description' => 'Fetches an object given its ID' , 'type' => $ nodeInterface , 'args' => [ 'id' => [ 'type' => Type :: nonNull ( Type :: id ( ) ) , 'description' => 'The ID of an object' ] ] , 'resolve' => function ( $ obj , $ args , $ context , $ info ) use ( $ idFetcher ) { return $ idFetcher ( $ args [ 'id' ] , $ context , $ info ) ; } ] ; return [ 'nodeInterface' => $ nodeInterface , 'nodeField' => $ nodeField ] ; }
Given a function to map from an ID to an underlying object, and a function
to map from an underlying object to the concrete GraphQLObjectType it
corresponds to, constructs a `Node` interface that objects can implement,
and a field config for a `node` root field.

If the typeResolver is omitted, object resolution on the interface will be
handled with the `isTypeOf` method on object types, as with any GraphQL
interface without a provided `resolveType` method.

@param callable $idFetcher
@param callable $typeResolver
@return array
Given a function to map from an ID to an underlying object and a function to map from an underlying object to the concrete GraphQLObjectType it corresponds to constructs a Node interface that objects can implement and a field config for a node root field .