Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mergeSchemas fails when using custom scalars #1530

Closed
danielrearden opened this issue May 24, 2020 · 2 comments
Closed

mergeSchemas fails when using custom scalars #1530

danielrearden opened this issue May 24, 2020 · 2 comments
Labels

Comments

@danielrearden
Copy link
Collaborator

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.

@ardatan ardatan added the bug label May 24, 2020
@yaacovCR
Copy link
Collaborator

Note that mergeSchemas in v5 = stitchSchemas in v6

This is still a bug, but using stitchSchemas might be a workaround

@ardatan ardatan added the waiting-for-release Fixed/resolved, and waiting for the next stable release label May 25, 2020
@ardatan
Copy link
Owner

ardatan commented May 25, 2020

Fixed in v6.0.1

@ardatan ardatan closed this as completed May 25, 2020
@yaacovCR yaacovCR removed the waiting-for-release Fixed/resolved, and waiting for the next stable release label Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants