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.

Hello. I have the same problem, so actually it would be very helpful to strip typename from data. For example fetch it from server use in cache normalization but do not send back to developer.

1 Like

This is actually a very old problem that people have been having for quite a while. First issue I can find is from over 4 years ago. Doesn’t seem like anything has been done to fix it.