@@ -44,6 +44,7 @@ import type {
4444 GraphQLDirective ,
4545 InputObjectTypeExtensionNode ,
4646 InterfaceTypeExtensionNode ,
47+ TypeDefinitionNode ,
4748} from "graphql" ;
4849import { GraphileEmbed } from "./gql" ;
4950
@@ -478,16 +479,32 @@ export default function makeExtendSchemaPlugin(
478479 } ) ;
479480
480481 builder . hook ( "GraphQLSchema" , ( schema , build , _context ) => {
482+ const { inflection } = build ;
481483 const {
482484 [ `ExtendSchemaPlugin_${ uniqueId } _typeExtensions` ] : typeExtensions ,
485+ [ `ExtendSchemaPlugin_${ uniqueId } _newTypes` ] : newTypeDefinitions ,
483486 } = build ;
487+ const newTypes = newTypeDefinitions . map (
488+ ( { definition } : { definition : TypeDefinitionNode } ) =>
489+ build . getTypeByName ( definition . name . value )
490+ ) ;
491+
484492 return {
485493 ...schema ,
486494 directives : [
487495 ...( schema . directives || build . graphql . specifiedDirectives || [ ] ) ,
488496 ...typeExtensions . GraphQLSchema . directives ,
489497 ] ,
490- types : [ ...( schema . types || [ ] ) , ...typeExtensions . GraphQLSchema . types ] ,
498+ types : [
499+ ...( schema . types || [ ] ) ,
500+ ...[
501+ build . getTypeByName ( inflection . builtin ( "Query" ) ) ,
502+ build . getTypeByName ( inflection . builtin ( "Mutation" ) ) ,
503+ build . getTypeByName ( inflection . builtin ( "Subscription" ) ) ,
504+ ] . filter ( _ => _ ) ,
505+ ...typeExtensions . GraphQLSchema . types ,
506+ ...newTypes ,
507+ ] ,
491508 } ;
492509 } ) ;
493510
0 commit comments