Repository navigation
Fix __typename at the query root - #964
hugo-vrijswijk wants to merge 1 commit into
Conversation
Queries with `__typename` at the root failed with `No field '__typename' for type Query`. The compiler used the introspection schema's `Query` type to resolve it. That type has no `__typename` field. This change resolves `__typename` against the enclosing type instead.
b7f7180 to
8259aba
Compare
__typename at the query root
milessabin
left a comment
There was a problem hiding this comment.
This is really useful ... thanks!
Just the issues I've flagged in the comments.
| } | ||
|
|
||
| nonIntroResults.map(_ ++ introResults) | ||
| nonIntroResults.map(typenameResults ++ _ ++ introResults) |
There was a problem hiding this comment.
In think this is going to mean that __typename always appears first in the result. eg. suppose we had { foo __typename } instead of { __typename foo }. I think there maybe similar pre-existing issues for non-top-level uses, but I'm pretty sure this is introducing a new instance.
| val expected = json""" | ||
| { | ||
| "data" : { | ||
| "__typename" : "Query", |
There was a problem hiding this comment.
It looks like the directive has been silently ignored here ... I'm pretty sure on main it would have been an error.
There was a problem hiding this comment.
On main this would fail (in nested fields) with Undefined directive 'upperCase'.. The directive not changing __typename or other introspection fields was an intentional change here.
The GraphQL spec says "it (typename) returns the name of the concrete Object type at that point during execution". So I don't think any user elaborators should be able to change introspection-level fields.
There was a problem hiding this comment.
Right, but I think we should still fail here in the same way as on main.
| ) | ||
| } | ||
|
|
||
| class TypenameShapesMapping extends ValueMapping[IO] { |
Queries with
__typenameat the root failed withNo field '__typename' for type Query. The compiler used the introspection schema'sQuerytype to resolve it. That type has no__typenamefield.This change resolves
__typenameagainst the enclosing type instead.