How to remove __typename for a specific query

My client requires __typename for the majority of the queries. but for some queries, I don’t really need it. I would like to know if it’s possible to remove the __typename field for specific queries rather than removing it in all the queries.

Hi @rabbit6147 :wave: - I work on the iOS client but I believe the principle is the same…

Fetching __typename is added automatically to queries and cannot be disabled because the cache requires it to be able to normalize the data. While it may not be needed in your application code, the cache makes assumptions about the presence of the type for normalization.


In the Apollo Client Web side, you can pass false to addTypename when creating an InMemoryCache. There is no equivalent feature for specific queries. One option is to create a second ApolloClient with an addTypename: false configured cache to the queries which you would like to not request typenames.

Like Calvin says, the typename information is usually critical for things like cache normalization. Is there a specific reason why you don’t want typenames to be added to queries?


Hi, thank you for the answers. Sometimes I would need to send the exact same response from the QueryA back to the server again from MutationA. and MutationA variables don’t have _typename in it. so I have to manually remove it from the response. And when there is many requirements it. becomes tedious to remove the __typname.