addTypename set to true does not add __typename to root selection set
See original GitHub issueIntended outcome:
I am using InMemoryCache
with addTypename
set to true
(the default). I expected __typename
to be added to all selection sets in my query, including the root selection set.
Actual outcome:
__typename
is added to all selection sets, but not the root object.
Because of this, the store defaults to “Query” as __typename for the root query object. My root query object is actually called “query_root”, and thus my type policy field settings for that object are not found during cache reads, even though I set queryType: true
on the “query_root” definition.
Adding __typename
explicitly to the root selection set of my queries works around this issue, but doesn’t it make sense for it to be added automatically when addTypenames is enabled?
How to reproduce the issue:
Create a client with an InMemoryCache that has addTypename
set to true
. Observe that __typename
is not added to root selection sets.
Versions
@apollo/client@3.3.0-rc.0
System: OS: macOS 10.15.4 Binaries: Node: 15.1.0 - /usr/local/bin/node Yarn: 1.22.10 - ~/dev/pony/src/front/node_modules/.bin/yarn npm: 7.0.8 - /usr/local/bin/npm Browsers: Chrome: 86.0.4240.198 Firefox: 81.0 Safari: 13.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (8 by maintainers)
Top GitHub Comments
Thank you @benjamn. I searched the codebase and somehow missed that.
Time is suddenly not on my side, but I will keep this in mind. Should be a fun exercise. Thanks again.
Let us know if this is still a concern with
@apollo/client@latest
- thanks!