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

Updating object added with cache.modify doesn't trigger watchQuery update (has failing unit test) #9440

Open
Narretz opened this issue Feb 17, 2022 · 0 comments

Comments

@Narretz
Copy link

Narretz commented Feb 17, 2022

Intended outcome:

I have a watchQuery with fetchPolicy network-only and nextFetchPolicy cache-first that returns an object with initially empty things.
Later, I add things to the object via cache.modify.
The watchQuery is triggered, it now contains the things.

Later, I call readQuery which updates one of the things with a new value.

I expect the watchQuery to be triggered again, with the new value for the thing.

See this unit test: #9439

the documentation says:

Like writeQuery and writeFragment, modify triggers a refresh of all active queries that depend on modified fields (unless you override this behavior by passing broadcast: false).

https://www.apollographql.com/docs/react/caching/cache-interaction/#using-cachemodify

Actual outcome:
After readQuery, the watchQuery is not triggered.

It is however triggered if I use cache.updateQuery to add the things.

That leads me to believe that this is a bug.

How to reproduce the issue:
I've added a failing unit test here:

#9439

Versions
Unit test ran against 3.5.9

@Narretz Narretz changed the title Updating object added with cache.modify doesn't trigger watchQuery update Updating object added with cache.modify doesn't trigger watchQuery update (has failing unit test) Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants