Do not call mergeSchema unless necessary

This commit is contained in:
SachaG 2019-03-12 21:54:50 +09:00
parent ab9bc3b73a
commit 26899c7ff6

View file

@ -75,7 +75,8 @@ const initGraphQL = () => {
resolvers: GraphQLSchema.resolvers,
schemaDirectives: GraphQLSchema.directives,
});
const mergedSchema = mergeSchemas({ schemas: [executableSchema, ...GraphQLSchema.stitchedSchemas] });
// only call mergeSchemas if we actually have stitchedSchemas
const mergedSchema = GraphQLSchema.stitchedSchemas.length > 0 ? mergeSchemas({ schemas: [executableSchema, ...GraphQLSchema.stitchedSchemas] }) : executableSchema;
GraphQLSchema.finalSchema = typeDefs;
GraphQLSchema.executableSchema = mergedSchema;