-
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
3.5.0 render frames of useQuery changed when variables change #9203
Comments
The effect on |
Possibly related to this: #9135 (comment) -- 3.5.6 fixed the Put another way: with this new render added in, if we update our query variables, how is our app supposed to know that |
A render frame with old data causes scrolling restoration problems in SPA with navigation based on browser history API. The issue leads to really annoying user experience. |
Hey folks - I think this may be related to the bug I filed yesterday with a repro case: #9333. I tested using 3.5.7 and also observed the variables property is immediately updated but the data is still old. |
Hi all, I'm doing some housekeeping and believe this issue was resolved by #9599. I'll close this for now but please reach out if you need more support 🙏🏻 |
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. |
In 3.5.0 the implementation of useQuery has been completely rewritten. Although no tests fail, the render behavior changed. There are some concerns with that:
Look at this test for example: "useQuery hook:General Use:should work with variables": https://github.com/apollographql/apollo-client/blob/main/src/react/hooks/__tests__/useQuery.test.tsx#L137
If you look at
result.all
at the end of the test, the frames will have values ofloading
anddata
like:Here is a rundown of why each frame happens:
In <3.5.0 frames 3 and 4 were combined and they theoretically can be again. Whether this should be changed comes down to ideology perhaps. Should a hook be permitted to add theoretically unnecessary render frames? Adding one extra frame in 4 frames isn't going to break the bank, but as it is there are no tests guaranteeing any kind of reasonable restriction. The code could add 10 extra render frames and all tests would still pass. I think that's a problem.
So I think we need to solve 2 problems:
We can achieve 1 by asserting the value of
result.all
, counting frames, and ensuring things happen exactly as we expect.We can achieve 2 by refactoring the internals.
result
is a state internally. Changing it to arefObject
allows for more fine-grained render-frame behavior.Is this a direction the Apollo team is willing to go? Or should users of this library figure out a way to deal with 'extra' render frames, and potentially unbound and undocumented changes to the render-frames?
The text was updated successfully, but these errors were encountered: