src/Schema/AST/ASTBuilder.php
protected function mergeTypeExtensions(DocumentAST $document): DocumentAST
    {
        $document->objectTypeDefinitions()->each(
            function (ObjectTypeDefinitionNode $objectType) use ($document) {
                $name = $objectType->name->value;

                $objectType = $document
                    ->extensionsForType($name)
                    ->reduce(
                        function (ObjectTypeDefinitionNode $relatedObjectType, ObjectTypeExtensionNode $typeExtension): ObjectTypeDefinitionNode {
                            $relatedObjectType->fields = ASTHelper::mergeUniqueNodeList(
                                $relatedObjectType->fields,
                                $typeExtension->fields
                            );

                            return $relatedObjectType;
                        },
                        $objectType
                    );

                // Modify the original document by overwriting the definition with the merged one
                $document->setDefinition($objectType);
            }
        );

        return $document;
    }
protected function mergeTypeExtensions(DocumentAST $document): DocumentAST
    {
        $document->objectTypeDefinitions()->each(
            function (ObjectTypeDefinitionNode $objectType) use ($document) {
                $name = $objectType->name->value;

                $objectType = $document
                    ->extensionsForType($name)
                    ->reduce(
                        function (ObjectTypeDefinitionNode $relatedObjectType, ObjectTypeExtensionNode $typeExtension): ObjectTypeDefinitionNode {
                            $relatedObjectType->fields = ASTHelper::mergeUniqueNodeList(
                                $relatedObjectType->fields,
                                $typeExtension->fields
                            );

                            return $relatedObjectType;
                        },
                        $objectType
                    );

                // Modify the original document by overwriting the definition with the merged one
                $document->setDefinition($objectType);
            }
        );

        return $document;
    }
protected function mergeTypeExtensions ( DocumentAST $ document ) : DocumentAST { $ document -> objectTypeDefinitions ( ) -> each ( function ( ObjectTypeDefinitionNode $ objectType ) use ( $ document ) { $ name = $ objectType -> name -> value ; $ objectType = $ document -> extensionsForType ( $ name ) -> reduce ( function ( ObjectTypeDefinitionNode $ relatedObjectType , ObjectTypeExtensionNode $ typeExtension ) : ObjectTypeDefinitionNode { $ relatedObjectType -> fields = ASTHelper :: mergeUniqueNodeList ( $ relatedObjectType -> fields , $ typeExtension -> fields ) ; return $ relatedObjectType ; } , $ objectType ) ; // Modify the original document by overwriting the definition with the merged one $ document -> setDefinition ( $ objectType ) ; } ) ; return $ document ; }
The final schema must not contain type extensions, so we merge them here.

@param  \Nuwave\Lighthouse\Schema\AST\DocumentAST  $document
@return \Nuwave\Lighthouse\Schema\AST\DocumentAST
The final schema must not contain type extensions so we merge them here .