Skip to content

Can we force __typename to be always present and not to be undefined? #423

Answered by kitten
vinassefranche asked this question in Q&A
Discussion options

You must be logged in to vote

This is explicitly not supported and __typename is only included when fetching. Generally, we deem this more correct and an easily spottable error, since using it will immediately result in TS type errors.

In urql Graphcache, we actually adhere to __typename inclusion, and Graphcache will reselect each selection, omitting __typename if it isn't included.

The problem here is that while Apollo Client implicitly queries it, it's still an implicit selection that could be removed, i.e. if you look at what Graphcache does, it's technically more "correct" behaviour to adhere to the original selection, which is why we can't assume the field to be there. (A link also exists for Apollo afaik to act…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by vinassefranche
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants