Skip to content

Possible to run updateQueryData before query is initiated #2668

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

Closed
frankleng opened this issue Sep 2, 2022 · 3 comments
Closed

Possible to run updateQueryData before query is initiated #2668

frankleng opened this issue Sep 2, 2022 · 3 comments

Comments

@frankleng
Copy link

frankleng commented Sep 2, 2022

I have an endpoint that doesn't need to fetch until a mutation occurs.

I'd like to implement optimistic update -
running updateQueryData once mutation starts, but has yet to be fulfilled..

but seems like running updateQueryData on an uninitiated query is a no-op. everything works fine if I fetch first.

is there a workaround? perhaps initiate it with empty state somehow?

@phryneas
Copy link
Member

phryneas commented Sep 2, 2022

This just rolled out with the latest alpha: #1720

@frankleng
Copy link
Author

This just rolled out with the latest alpha: #1720

awesome. thank you!

@phryneas
Copy link
Member

phryneas commented Sep 3, 2022

But please be aware that it seems there was a bug in that alpha release that prevented upserts from actually happening. See the thread above where we discussed that - #2669 contains a fix and a CodeSandbox CI build of the package you can install and use.

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

No branches or pull requests

2 participants