question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Turning off __typename consequences

See original GitHub issue

Hey, there are a lot of issues about __typename added to data. There are use cases when you want to receive data exactly as it was asked. The advised solutions were to manually deeply remove __typename from data or to turn this off with addTypename: false.

What are the consequences of turning this off with addTypename: false, will it break cache somehow/make it slower/etc ?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
ikatuncommented, Jan 18, 2019

We dumped the react-apollo all together and switched to using our own library which exposes apollo through mobx. The library itself filters the extraneous __typename field.

Internally, it all just comes to this function

function removeTypename(data) {
  return typeof data === 'object' ? objectKeyFilter(data, ['__typename'], true) : data;
}

and then (for example in render function/method)

const cleanData = removeTypename(dataFromApollo);

objectKeyFilter being https://www.npmjs.com/package/object-key-filter

2reactions
ikatuncommented, Jul 28, 2018

If you want to avoid having to manually remove __typename from every response, you can just require this module https://www.npmjs.com/package/typename-monkey-patch somewhere near the entry point of your app. It monkey patches graphql HOC from react-apollo so that __typename is removed before sending data to your wrapped component.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to remove the `__typename` field from the graphql ...
js:28 DEPRECATION WARNING: using fragments without __typename is unsupported behavior and will be removed in future versions of Apollo client.
Read more >
Demystifying Cache Normalization - Apollo GraphQL Blog
Application-specific side-effects are things that you want to happen to the cache after a mutation that may not use anything from the response ......
Read more >
Compiler Warning (level 3) C4996 - Microsoft Learn
Turn off the warning for a project in Visual Studio · Open the Property Pages dialog for your project. For information on how...
Read more >
What are consequences of changing Record Type Name
Why are wire transfers not reversible by the bank? Is it bad practice to regularly turn a circuit breaker off/on? Meaning of 'Bessel...
Read more >
Disable Implicit Casts - Gockel Hut
The compiler will happily add an implicit cast to transform the argument to a 5 . Most compilers have warnings that can be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found