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

Fatal exception in merge.mergeType - argument validation bug #2629

Closed
b-jsshapiro opened this issue Feb 22, 2021 · 2 comments
Closed

Fatal exception in merge.mergeType - argument validation bug #2629

b-jsshapiro opened this issue Feb 22, 2021 · 2 comments

Comments

@b-jsshapiro
Copy link

Describe the bug
When attempting to merge interfaces, mergeType blindly calls mergeNamedTypeArray, which does not check if its first argument is, in fact, an array. The interfaces field is optional in ObjectTypeDefinitionNode. When no interfaces are present, the effect is that the node.interfaces value passed as the first argument to mergeNamedTypeArray is undefined. When, having failed to check the argument, mergeNamedTypeArray calls first.filter(), bad things happen. :-)

For now, a workaround is to define interfaces with an empty list in the AST works around the problem, but I'm not clear if various SDL->AST translators routinely do this (have not tested).

Suggested fix: Add default [] parameter values for the first and second parameters to mergeNamedTypeArray, similar to what is done for parameters at mergeDirectives.

To Reproduce
Pass a DocumentNode in the typeDefs parameter to mergeSchemas that contains an ObjectTypeDefinitionNode whose interfaces field is undefined.

Expected behavior
Should not throw on well-formed input...

Environment:

graphql-tools/merge 6.2.9, but bug is also present in current github.

Additional context

@ardatan
Copy link
Owner

ardatan commented Apr 14, 2021

@b-jsshapiro Would you create a PR with a fix and test?

@ardatan
Copy link
Owner

ardatan commented May 11, 2021

Fixed in eae2879

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

No branches or pull requests

2 participants