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

Unable to merge GraphQL type ... undefined is not iterable (for a duplicate type) #414

Open
kumar303 opened this issue Apr 8, 2021 · 3 comments

Comments

@kumar303
Copy link

kumar303 commented Apr 8, 2021

Using [email protected], I was trying to call something like:

import {mergeTypes} from 'merge-graphql-schemas';

(async () => {
    mergeTypes(
      await Promise.all([
        fs.readFile('schema1.graphql'),
        fs.readFile('schema2.graphql'),
      ]),
    );
})();

I got an error like:

Error: Unable to merge GraphQL type "MyType": undefined is not iterable (cannot read property Symbol(Symbol.iterator))
    at mergeType (/.../app/node_modules/@graphql-toolkit/schema-merging/index.cjs.js:675:19)
    at /.../app/node_modules/@graphql-toolkit/schema-merging/index.cjs.js:717:30
    at Array.reduce (<anonymous>)
    at mergeGraphQLNodes (/.../app/node_modules/@graphql-toolkit/schema-merging/index.cjs.js:706:18)
    at mergeGraphQLTypes (/.../app/node_modules/@graphql-toolkit/schema-merging/index.cjs.js:856:25)
    at Object.mergeTypeDefs (/.../app/node_modules/@graphql-toolkit/schema-merging/index.cjs.js:755:22)
    at mergeTypes (/.../app/node_modules/merge-graphql-schemas/dist/index.cjs.js:24:26)
    ...

I was trying to introduce type MyType {} in schema1.graphql but that exact type already existed in schema2.graphql.

This error message should be more informative. RIP my last hour.

@ardatan
Copy link
Collaborator

ardatan commented Apr 9, 2021

merge-graphql-schemas has been deprecated as you can see in https://github.com/Urigo/merge-graphql-schemas/blob/master/README.md We recommend you to start using GraphQL Tools instead;
https://www.graphql-tools.com/docs/migration-from-merge-graphql-schemas/

@kumar303
Copy link
Author

kumar303 commented Apr 9, 2021

Since I have the solution, I just wanted to post it here so that someone else could search and find it. I was trying to search for this error and not finding anything.

Ultimately, I'd hope the newer lib has a better error message but I'm not able to migrate my app at this time.

@ArtemKislov
Copy link

ArtemKislov commented Dec 9, 2021

@kumar303

Since I have the solution, I just wanted to post it here so that someone else could search and find it. I was trying to search for this error and not finding anything.

You have just saved me an hour :) thanks for the explanation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants