extendSchema incorrectly throws "multiple types" error when input type used as a query argument. #1355
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As per the New Issue template, this PR contains a failing unit test showing the issue (I don't have a fix).
Here's a live example you can play around with: https://codesandbox.io/s/9orv5vlovw?module=%2Fsrc%2Findex.js
The error received is:
I've had a stab at tracking it down, and it looks like it arises due a reference inequality between two objects. When investigating the two objects, their structures appear to be slightly different:
Stepping through the code, I noticed the first instance of
FooInput
to be put in themap
(map[type.name]
in the screenshot above) is the one encountered as part of recursing intotype Query { foo(where: FooInput ...
. Not sure if that helps at all?Note also that manually building the schema (ie; not parsing from the SDL) doesn't appear to exhibit this bug (hence the addition of the
FooInput
GraphQLInputObjectType
in this PR). I'm not sure if that's because I'm miss-understanding the way the code executes, or because of a fundamental difference in how the schemas are handled when extending?