apollographql / apollo-client

:rocket:  A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.
https://apollographql.com/client
MIT License
19.37k stars 2.66k forks source link

__typename isn't added automatically to queries that use __type( #2045

Closed happylinks closed 7 years ago

happylinks commented 7 years ago

Intended outcome: GraphQL queries that use type( should also get the typename added to them automatically. Correct query should be:

query getLanguages {
    languages: __type(name: "DefaultLanguage") {
        name
        __typename
        enumValues {
            name
            __typename
        }
   }
}

Actual outcome: When you have a query like:

query getLanguages {
    languages: __type(name: "DefaultLanguage") {
        name
        enumValues {
            name
        }
    }
}

The __typename will not be added in the correct places. (see first query) This causes persisted queries to not work anymore for these specific queries; it will not find the query in the query map.

How to reproduce the issue: Check it here: https://codesandbox.io/s/voxg0yAnm

  1. Make a query which uses __type in it.
  2. Check which query is being send to the server. (network tab)
  3. The __typename is not sent.

Temporary solution: Add typename to the type queries yourself.

Version

Related Github Issues: https://github.com/sysgears/persistgraphql-webpack-plugin/issues/11 https://github.com/apollographql/apollo-client/pull/228

stale[bot] commented 7 years ago

This issue has been automatically marked as stale becuase it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions to Apollo Client!

happylinks commented 7 years ago

I'm keeping it alive for now. Will probably pick it up myself when I have the time. (Any hints would be nice though)

stale[bot] commented 7 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions to Apollo Client!

stale[bot] commented 7 years ago

This issue has been automatically closed because it has not had recent activity after being marked as stale. If you belive this issue is still a problem or should be reopened, please reopen it! Thank you for your contributions to Apollo Client!