src/Schema/AST/ASTBuilder.php
protected function addNodeSupport(DocumentAST $document): DocumentAST
    {
        $hasTypeImplementingNode = $document
            ->objectTypeDefinitions()
            ->contains(function (ObjectTypeDefinitionNode $objectType): bool {
                return (new Collection($objectType->interfaces))
                    ->contains(function (NamedTypeNode $interface): bool {
                        return $interface->name->value === 'Node';
                    });
            });

        // Only add the node type and node field if a type actually implements them
        // Otherwise, a validation error is thrown
        if (! $hasTypeImplementingNode) {
            return $document;
        }

        $globalId = config('lighthouse.global_id_field');
        // Double slashes to escape the slashes in the namespace.
        return $document
            ->setDefinition(
                PartialParser::interfaceTypeDefinition(<<<GRAPHQL
"Node global interface"	
interface Node @interface(resolveType: "Nuwave\\\Lighthouse\\\Schema\\\NodeRegistry@resolveType") {	
  "Global identifier that can be used to resolve any Node implementation."
  $globalId: ID!	
}	
GRAPHQL
                )
            )
            ->addFieldToQueryType(
                PartialParser::fieldDefinition(
                    'node(id: ID! @globalId): Node @field(resolver: "Nuwave\\\Lighthouse\\\Schema\\\NodeRegistry@resolve")'
                )
            );
    }
protected function addNodeSupport(DocumentAST $document): DocumentAST
    {
        $hasTypeImplementingNode = $document
            ->objectTypeDefinitions()
            ->contains(function (ObjectTypeDefinitionNode $objectType): bool {
                return (new Collection($objectType->interfaces))
                    ->contains(function (NamedTypeNode $interface): bool {
                        return $interface->name->value === 'Node';
                    });
            });

        // Only add the node type and node field if a type actually implements them
        // Otherwise, a validation error is thrown
        if (! $hasTypeImplementingNode) {
            return $document;
        }

        $globalId = config('lighthouse.global_id_field');
        // Double slashes to escape the slashes in the namespace.
        return $document
            ->setDefinition(
                PartialParser::interfaceTypeDefinition(<<<GRAPHQL
"Node global interface"	
interface Node @interface(resolveType: "Nuwave\\\Lighthouse\\\Schema\\\NodeRegistry@resolveType") {	
  "Global identifier that can be used to resolve any Node implementation."
  $globalId: ID!	
}	
GRAPHQL
                )
            )
            ->addFieldToQueryType(
                PartialParser::fieldDefinition(
                    'node(id: ID! @globalId): Node @field(resolver: "Nuwave\\\Lighthouse\\\Schema\\\NodeRegistry@resolve")'
                )
            );
    }
protected function addNodeSupport ( DocumentAST $ document ) : DocumentAST { $ hasTypeImplementingNode = $ document -> objectTypeDefinitions ( ) -> contains ( function ( ObjectTypeDefinitionNode $ objectType ) : bool { return ( new Collection ( $ objectType -> interfaces ) ) -> contains ( function ( NamedTypeNode $ interface ) : bool { return $ interface -> name -> value === 'Node' ; } ) ; } ) ; // Only add the node type and node field if a type actually implements them // Otherwise, a validation error is thrown if ( ! $ hasTypeImplementingNode ) { return $ document ; } $ globalId = config ( 'lighthouse.global_id_field' ) ; // Double slashes to escape the slashes in the namespace. return $ document -> setDefinition ( PartialParser :: interfaceTypeDefinition ( <<<GRAPHQL
"Node global interface"	
interface Node @interface(resolveType: "Nuwave\\\Lighthouse\\\Schema\\\NodeRegistry@resolveType") {	
  "Global identifier that can be used to resolve any Node implementation."
  $globalId: ID!	
}	
GRAPHQL ) ) -> addFieldToQueryType ( PartialParser :: fieldDefinition ( 'node(id: ID! @globalId): Node @field(resolver: "Nuwave\\\Lighthouse\\\Schema\\\NodeRegistry@resolve")' ) ) ; }
Inject the node type and a node field into Query.

@param  \Nuwave\Lighthouse\Schema\AST\DocumentAST  $document
@return \Nuwave\Lighthouse\Schema\AST\DocumentAST
Inject the node type and a node field into Query .