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

useQuery does not rollback optimistic response after network error

Open georeith opened this issue 5 years ago • 1 comments

Note: I originally made this issue in apollo-client by mistake: https://github.com/apollographql/apollo-client/issues/5215

Intended outcome: After a network error (forced by setting 'Offline' in Chrome developer tools) I would expect the data from a query to be rolled back to before it was updated by the optimistic response (as it does for graphQl errors).

Actual outcome: The store gets rolled back but if I have multiple useQuery looking at the same data only one of them updates correctly.

How to reproduce the issue:

I have made a reproduction of the issue here: https://github.com/georeith/react-apollo-error-template-5215

The issue happens when you have two (or more) useQuery reading overlapping data using different query objects. One of the queries will update correctly after the network error, the others will not.

issue

Versions

System: OS: macOS High Sierra 10.13.6 Binaries: Node: 10.4.1 - ~/.nvm/versions/node/v10.4.1/bin/node Yarn: 1.17.3 - /usr/local/bin/yarn npm: 6.1.0 - ~/.nvm/versions/node/v10.4.1/bin/npm Browsers: Chrome: 76.0.3809.100 npmPackages: react-apollo: ^3.0.1 => 3.0.1

georeith avatar Aug 21 '19 11:08 georeith

Does anyone have a workaround for this?

levidyrek avatar May 01 '20 16:05 levidyrek