Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cache.identify for ROOT_QUERY #9377

Open
Mangatt opened this issue Jan 31, 2022 · 3 comments
Open

cache.identify for ROOT_QUERY #9377

Mangatt opened this issue Jan 31, 2022 · 3 comments
Labels
🏓 awaiting-team-response requires input from the apollo team

Comments

@Mangatt
Copy link

Mangatt commented Jan 31, 2022

Intended outcome:

There should be a way how to use cache.identify with ROOT_QUERY and keyArgs. If there is already a way, it should be documented.

Actual outcome:

There is currently no (apparent) way how to get an ID from cache with keyArgs.

How to reproduce the issue:

ROOT_QUERY
__typename:"Query"
comments:{"channellId":"1"}: [] 1 item
comments:{"channellId":"2"}: [] 11 items

None of following works:

cache.identify({__typename: 'comments', channellId: '1'}
cache.identify({__typename: 'Query', comments: {channellId: '1'}}
cache.identify({__typename: 'ROOT_QUERY', comments: {channellId: '1'}}

Versions

@apollo/client 3.5.7
OS: Windows 10 10.0.19044
Node: 17.4.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.15 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 8.3.1 - C:\Program Files\nodejs\npm.CMD
Chrome: 97.0.4692.99

@benjamn
Copy link
Member

benjamn commented Feb 2, 2022

@Mangatt Unless you're defining a custom keyFields array or dataIdFromObject function for the Query type, and it includes the comments field (unusual), the comments data should be ignored by cache.identify.

When I run cache.identify({ __typename: "Query" }) I get ROOT_QUERY back. It doesn't make a difference (for me) if I include any other fields, like comments.

Is there any chance you might be reconfiguring the default query __typename using queryType: true for some type other than Query?

@benjamn benjamn added the 🏓 awaiting-contributor-response requires input from a contributor label Feb 2, 2022
@Mangatt
Copy link
Author

Mangatt commented Mar 3, 2022

Hello @benjamn , sorry for the late reply. No, I'm not reconfiguring __typename in any way.

@Mangatt
Copy link
Author

Mangatt commented Mar 3, 2022

I'm not sure if my question was clear enough - I need to get back from cache.identify string comments:{"channellId":"1"}, not ROOT_QUERY.

@benjamn benjamn added 🏓 awaiting-team-response requires input from the apollo team and removed 🏓 awaiting-contributor-response requires input from a contributor labels May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏓 awaiting-team-response requires input from the apollo team
Projects
None yet
Development

No branches or pull requests

2 participants