React-apollo: [Regression] fetchMore option updateQuery triggers hook update but with previous data

Created on 19 Nov 2019  路  7Comments  路  Source: apollographql/react-apollo

This issue is present again.

Intended outcome:
To get in data object of useQuery hook result of updateQuery function which was provided as option in fetchMore call.

Actual outcome:
Getting in data object in useQuery hook PREVIOUS result of updateQuery function which was provided as option in fetchMore call or original result of a query (if it was the first call to fetchMore).

Version
[email protected] and further releasess

Reproduction
https://codesandbox.io/s/quizzical-goldberg-chfj2

Most helpful comment

Maybe related issue. We also get PREVIOUS result here.

https://github.com/apollographql/react-apollo/issues/3640

All 7 comments

We have the same problem. Any ideas how to solve it?

Maybe related issue. We also get PREVIOUS result here.

https://github.com/apollographql/react-apollo/issues/3640

Facing the same issue here

Any clues on this one? This is a big issue :/

I have the same issue. My current workaround is to keep track of the already fetched pages in a ref and ignore calls to fetchMore if the page is already fetched.

Note that Apollo triggers another render with the correct data.

This is supposedly fixed in the next version: https://github.com/apollographql/react-apollo/issues/3333#issuecomment-577882189.

I have the same problem, I can add more information :

  • it happens randomly: sometimes after the second calls, sometimes after the fifth, ...
  • The network call is the right one: When I inspect the network, the right calls is made on the server but the data received in updateQuery is the previous result

I'm using useQuery from @apollo/react-hooks

It's happening when usingfetchPolicy: 'cache-and-network'.
I am running on the latest v.3 beta.48

Was this page helpful?
0 / 5 - 0 ratings