I am trying to use graphql tool to perform schema stitching. However, if I pass more than one schema, it throws 2 error.
sometimes it throws
Object.keys(source).forEach(key => {
^
RangeError: Maximum call stack size exceeded
Or
\'use strict';
^
RangeError: Maximum call stack size exceeded
My schema setup is pretty simple. I only have 2 schema Country and City. Those also have UUID, JSON scalar types.
import {
makeExecutableSchema,
mergeSchemas,
} from 'graphql-tools'
import GraphQLUUID from 'graphql-type-uuid'
import GraphQLJSON from 'graphql-type-json'
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
scalar JSON
type City {
id: UUID!
name: String
coordinates: JSON
}
type Query {
city: City
}
`,
resolvers: {
UUID: GraphQLUUID,
JSON: GraphQLJSON,
}
})
const resolvers = {
Query: {
country: () => ({ id: '2ij29fij390f3j', name: 'Toronto'}),
city: () => ({id: '2ij29fij390f3j11', name: 'Toronto', coordinates: "[]"})
}
}
export const schema = mergeSchemas({
schemas: [ countrySchema, citySchema],
resolvers: resolvers
});
Funny thing is that If I pass either countrySchema or citySchema to schemas array. It works. but both of them throws error I mentioned above.
Please share your thoughs.
This appears to be a regression introduced by version 6.0.0 of graphql-tools
. Bump your version down to 5.0.0 by running npm install graphql-tools@5.0.0
. If an issue hasn't been opened already, you can open one on Github for this bug.