react-apollo icon indicating copy to clipboard operation
react-apollo copied to clipboard

[Regression] fetchMore option updateQuery triggers hook update but with previous data

Open AlpacaGoesCrazy opened this issue 6 years ago • 7 comments

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

AlpacaGoesCrazy avatar Nov 19 '19 08:11 AlpacaGoesCrazy

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

mrbalov avatar Nov 20 '19 15:11 mrbalov

Maybe related issue. We also get PREVIOUS result here.

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

mrbalov avatar Nov 20 '19 15:11 mrbalov

Facing the same issue here

iamrommel avatar Dec 27 '19 07:12 iamrommel

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

Emiliano-Bucci avatar Jan 16 '20 19:01 Emiliano-Bucci

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.

amannn avatar Feb 14 '20 09:02 amannn

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

Kisepro avatar Feb 16 '20 11:02 Kisepro

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

perrosnk avatar May 17 '20 19:05 perrosnk