Graphql-tools: mergeSchemas fails when using custom scalars

Created on 24 May 2020  Â·  2Comments  Â·  Source: ardatan/graphql-tools

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.

bug

All 2 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Adherentman picture Adherentman  Â·  4Comments

freiksenet picture freiksenet  Â·  4Comments

capaj picture capaj  Â·  4Comments

alfaproject picture alfaproject  Â·  4Comments

stubailo picture stubailo  Â·  3Comments