-
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
Behavior change: In v3.5+, minimal useQuery example briefly returns old data after variables changed #9333
Comments
I just stumbled upon this problem on our production system today. It seems that for 1 render, the variables passed in are new, the data returned is still old, while loading is also I do have a loading state in my app, but how can I know that the returned This is causing me some problems, since I rely on The only way for me to check if the data is correct, was actually to compare the input variables with the returned data. This is not ideal, since not every graphql query returns all it's varaibles. @bengotow Did you find a (at least temporary) solution to the problem? @benjamn Is this an intentional change? If so, how do I determine whether |
@whytspace Same issue, the added |
This looks a lot like the issue I am having as well. #9340 I can confirm that rolling back our Apollo Client from v3.5.8 to v3.4.17 has fixed the issue. |
This is a huge regression for us as well. I would expect the |
This seems to be fixed with the new 3.6.0 release. The render immediate following a variable change now has |
Yes this was fixed by #9599 which should be available in v3.6.0 |
Hi all, I'm closing this issue as resolved due to the above. Please do reach out if you need more support here 🙏🏻 |
Intended outcome:
Prior to Apollo Client 3.5, changes to the variables provided to a
useQuery
hook were immediately reflected in the hook's returned data (within the same render).Actual outcome:
Starting with Apollo Client 3.5, the useQuery hook returns data for old variables for at least one render after new variables are provided, rather than returning cached data / empty data / a loading state that reflects the new variables.
This is a serious regression and it seems that it can't be easily detected. If you inspect the return value of the hook in the render when variables are changed:
How to reproduce the issue:
I've created a super small reproduction case with CRA + Typescript here:
https://github.com/bengotow/apollo-client-issues/blob/new-variables-old-data/src/AppNewVariablesOldDataBug.tsx
To trigger the bug, click
Switch Fruit Family
to set a new variable value. The app crashes at an assertion check.Findings:
If you change back to an earlier version of Apollo Client (my team was using 3.3.16), the useQuery's result reflects the new variables immediately and the app does not crash.
I've turned off caching entirely (using
new InMemoryCache({resultCaching: false})
) to make sure those settings weren't the cause.Versions
The text was updated successfully, but these errors were encountered: