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

useQuery refreshing with the wrong data (corresponding to previous variables) #11184

Closed
adianabob opened this issue Aug 30, 2023 · 3 comments · Fixed by #11186
Closed

useQuery refreshing with the wrong data (corresponding to previous variables) #11184

adianabob opened this issue Aug 30, 2023 · 3 comments · Fixed by #11186
Assignees
Labels

Comments

@adianabob
Copy link

Issue Description

I use useQuery to fetch the data depending on some variables.

I trigger the query with a set of variables, the data is being stored in the cache. Then, I trigger the same query with different variables, but the query takes a long time. While the second call is still pending in the network, I trigger the query with the initial variables => I will instantly have the data from the cache. Once the pending query is resolved, the useQuery will return the new data, even if it doesn't correspond to the actual variables anymore, resulting in inconsistent data displayed on the dashboard.

apollo/client version: 3.8.0

More details in the thread : https://discord.com/channels/1022972389463687228/1143184015877214228
@jerelmiller as discussed, I am tagging you here

Link to Reproduction

https://github.com/adianabob/apollo-client-demo

Reproduction Steps

apollo-client.mov
@jerelmiller
Copy link
Member

Hey @adianabob 👋

I've opened #11186 which fixes the issue. If you want to try a snapshot release and make sure it works in your app as expected, you can install it via:

npm i @apollo/client@0.0.0-pr-11186-20230831064231

I've tried this snapshot release in your reproduction with success.

We should be able to get this fix in the next patch release or two (depending on when the PR is merged). Thanks for reporting the bug!

@adianabob
Copy link
Author

Hi @jerelmiller ! :)
I tried the fix in our project and it works! I will follow the PR to see when it's merged.
Thanks a lot for the fast and great work!
Feel free to close the issue from my side :)

@github-actions
Copy link
Contributor

github-actions bot commented Oct 2, 2023

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.
For general questions, we recommend using StackOverflow or our discord server.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
2 participants