Skip to content
New issue

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

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

Already on GitHub? # to your account

Field is cached separately when args are not set vs set to null #12365

Open
jbachhardie opened this issue Feb 11, 2025 · 2 comments
Open

Field is cached separately when args are not set vs set to null #12365

jbachhardie opened this issue Feb 11, 2025 · 2 comments
Labels

Comments

@jbachhardie
Copy link

Issue Description

When a query omits arguments from a field that field is cached as fieldName whereas when a query defined those arguments as optional but then they are not passed in as variables it is cached as fieldName({}) despite both of those cases being identical from the point of view of the GraphQL server. This is surprising and causes an issue where a query with the ability to set field arguments can never read from a cache set by a query that does not have those arguments, no matter what variables are set.

Link to Reproduction

https://codesandbox.io/p/devbox/damp-star-6vkn89?workspaceId=ws_NweYYNTBLCG39JiWfDJEb

Reproduction Steps

Click on "Switch" and watch the components switch from a query without args to one with args but where they're not set in the variables. These two queries should share a single cached value but they do not, two different values are stored.

@apollo/client version

3.11.4

Copy link

triagster bot commented Feb 11, 2025

Related issues:

Was this useful? Use the reactions below to give feedback.

@phryneas
Copy link
Member

Thank you for bringing this up - I've opened #12370 to address this. Could you please try out the PR build from that issue and report back if it behaves as expected for you now?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants