As of version 6.0.0, mergeSchemas appears to fail when merging schemas with custom scalars. I was able to reproduce the issue in this SO post. Here's a simplified reproduction:
const { mergeSchemas, makeExecutableSchema } = require("graphql-tools");
const GraphQLUUID = require('graphql-type-uuid')
const countrySchema = makeExecutableSchema({
typeDefs: `
scalar UUID
type Country {
id: UUID!
name: String
}
type Query {
country: Country
}
`,
resolvers: {
UUID: GraphQLUUID,
}
})
const citySchema = makeExecutableSchema({
typeDefs: `
scalar UUID
type City {
id: ID!
name: String
}
type Query {
city: City
}
`,
})
const schema = mergeSchemas({
schemas: [countrySchema, citySchema],
});
The resulting error:
RangeError: Maximum call stack size exceeded
at Function.assign (<anonymous>)
at Object.keys.forEach.key (.../node_modules/@graphql-tools/utils/index.cjs.js:2651:28)
at Array.forEach (<anonymous>)
at sources.forEach (.../node_modules/@graphql-tools/utils/index.cjs.js:2641:33)
at Array.forEach (<anonymous>)
at mergeDeep (.../node_modules/@graphql-tools/utils/index.cjs.js:2639:13)
at Object.keys.forEach.key (.../node_modules/@graphql-tools/utils/index.cjs.js:2647:39)
at Array.forEach (<anonymous>)
at sources.forEach (.../node_modules/@graphql-tools/utils/index.cjs.js:2641:33)
at Array.forEach (<anonymous>)
Bumping the version down to 5.0.0 fixes the issue. Removing the custom scalar also fixes the issue.
Note that mergeSchemas in v5 = stitchSchemas in v6
This is still a bug, but using stitchSchemas might be a workaround
Fixed in v6.0.1