-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
The onCompleted
callback of useQuery
executes from cache writes.
#10076
Comments
As you suspected, this is very likely the same underlying issue as #10059. |
Hi @bignimbus, I'm quite confused about your comment and how it relates to my issue. Is it possible your comment/issue-close here was meant for a different issue? I see you had a recent docs PR here, https://github.com/apollographql/apollo-client/pull/10066/files, but with that I still don't see how it relates to my ask here. |
You're quite right @lawrence-yu, sorry for the confusion! I've deleted the comment and will repost it where it belongs. |
Seems we have the same error:
|
Same problem here, And Im using Apollo 3.6.9 |
Thanks for the reproduction, @lawrence-yu! #10229 is open with the fix, I'll update this issue again when it's merged and released 🙇♀️ |
The fix is now available in the current 3.8 |
Hi all - I'm going to close this issue out since this is fixed in a prerelease. Feel free to install the latest alpha with the command above. Thanks! |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Intended outcome:
The
onCompleted
option provided touseQuery
should not be called after data was changed from an update viacache.writeQuery
(where it was just a local cache update without a network request).Actual outcome:
When using
cache.writeQuery
to update local data, theonCompleted
option of auseQuery
for the same query gets called. This is a change from what we see on 3.4.x, where theonCompleted
callback is not called after these cache updates.How to reproduce the issue:
https://github.com/lawrence-yu/react-apollo-error-onCompleted
1
to a person's name, which is reflected in UI with the list of names.3.4.17
branch in the fork that can be used to see that, with each button click, theonCompleted
count remains at 1 (the one being from after initial query completion).Versions
Other notes
The limited documentation for the
onCompleted
option leaves me unsure about what is the "correct" behavior. Is getting called by cache updates actually correct now? Or was the old behavior correct and this is an actual bug?Potentially related to:
#9688
#10059
The text was updated successfully, but these errors were encountered: