extendSchema incorrectly throws "multiple types" error when input type used as a query argument.#1355
extendSchema incorrectly throws "multiple types" error when input type used as a query argument.#1355jesstelford wants to merge 1 commit intographql:masterfrom
Conversation
| Sooo, it turns out it was a typo... I do wonder though if a better error message could have been generated here? Should |
| @jesstelford Thanks a lot for the test it helped a lot 👍 graphql-js/src/utilities/extendSchema.js Lines 163 to 166 in f3ebab8 That's why we assume that it safe to just copy args without updating their types, see line 374: graphql-js/src/utilities/extendSchema.js Lines 369 to 374 in f3ebab8 It's already fixed as part of #1322 which allows to extend input types.
Already handled, see this test: graphql-js/src/type/__tests__/validation-test.js Lines 1270 to 1277 in f3ebab8
We try validate schema only once per schema to improve perfomance on big schema and provide better DX (you get all errors at once) so schema validated first time you call graphql-js/src/execution/execute.js Lines 276 to 277 in f3ebab8 |
| Fixed in #1373 |
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
FooInputto 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
FooInputGraphQLInputObjectTypein 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?