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")'
                )
            );
    }