How to remove the `__typename` field from the graphql response which fails the mutations

Rigin Oommen picture Rigin Oommen · Mar 20, 2019 · Viewed 12.7k times · Source

I tried changing the addTypeName: false in the Apollo client in GraphQL

apollo.create({
  link: httpLinkWithErrorHandling,
  cache: new InMemoryCache({ addTypename: false }),
  defaultOptions: {
    watchQuery: {
      fetchPolicy: 'network-only',
      errorPolicy: 'all'
    }
  }

But it works and it throws the following messages in the console

fragmentMatcher.js:26 You're using fragments in your queries, but either don't have the addTypename:true option set in Apollo Client, or you are trying to write a fragment to the store without the __typename.Please turn on the addTypename option and include __typename when writing fragments so that Apollo Clientcan accurately match fragments.

,

Could not find __typename on Fragment  PopulatedOutageType

and

fragmentMatcher.js:28 DEPRECATION WARNING: using fragments without __typename is unsupported behavior and will be removed in future versions of Apollo client. You should fix this and set addTypename to true now.

even if i change false to true new InMemoryCache({ addTypename: true }), the mutations start failing because of the unwanted typename in the mutation

is there any way to resolve this issue

Answer

Rigin Oommen picture Rigin Oommen · Apr 12, 2019

Cleaning Unwanted Fields From GraphQL Responses

In the above thread, I have posted the answer for this problem please refer to it