graphql-client icon indicating copy to clipboard operation
graphql-client copied to clipboard

Interfaces don't work without explicitly querying `__typename`

Open deecewan opened this issue 2 years ago • 0 comments

I have a GraphQL interface I'm writing a query against. The query executes successfully, but I get an InvariantError from here:

https://github.com/github/graphql-client/blob/8fb3a8a75e90212d41e5fcf42305e8afac7599fc/lib/graphql/client/schema/possible_types.rb#L44

After looking at the code, it seems like __typename must be queried on interface types. As far as I know, that's not a requirement, because the fields being queried are shared across all the interfaces.

Looks like #75 references this and #157 mentions it. I'm not sure what's expected, but it feels like there should be some documentation (like there is for the ImplicitlyFetchFieldError) to tell people how to fix it. OR maybe I've missed something in the GQL spec that requires it.

deecewan avatar May 19 '22 14:05 deecewan