Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

refetch issues on new rc versions #642

Closed
msmfsd opened this issue Apr 20, 2017 · 8 comments
Closed

refetch issues on new rc versions #642

msmfsd opened this issue Apr 20, 2017 · 8 comments

Comments

@msmfsd
Copy link

msmfsd commented Apr 20, 2017

NOTE: this is an issue only with release candidate v1.0.0+ of react-apollo and apollo-client. If this has been fixed in newer versions this can be closed.

Steps to Reproduce

  1. Update react-apollo & apollo-client to 1.0.0-rc.3 & 1.0.0-rc.6.
  2. Replace forceFetch config option with new fetchPolicy: 'network-only' option on any queries.
  3. Have a refetch button onClick={() => refetch()} that appears on any graphql error on your graphql component.
  4. Load that component and simulate a network status error, eg stop your local server.
  5. Click your refetch button, start server again, click refetch again etc.

Buggy Behavior

On click of refetch no new request is made to the server, it appears, possibly, that react-apollo initiates an action but sees the error in the apollo store and doesnt make a new network request.

Expected Behavior

Refetch should make a new network request to the server and change loading to true, networkStatus to 4 and then update loading, networkStatus & error depending on the network response.

Version

  • apollo-client@1.0.0-rc.6
  • react-apollo@1.0.0-rc.3

Related issue

#636

@helfer
Copy link
Contributor

helfer commented Apr 21, 2017

Hi @msmfsd, could you try this with the most recent versions of react-apollo and apollo-client? The rc's are a few weeks old and we've fixed a couple of bugs since then.

@msmfsd
Copy link
Author

msmfsd commented Apr 21, 2017

Thanks @helfer I have updated and can confirm fetchPolicy: 'network-status' works as expected and refetch triggers a new network request.

However after a network error if you do a refetch the networkStatus remains at 8 (error) and thus loading remains false. Only once refetch is successfull does networkStatus change to 7.

So my question, is refetch meant to update the networkStatus to 4 and thus loading to true?

@helfer
Copy link
Contributor

helfer commented Apr 21, 2017

@msmfsd yes, I think the loading status should change to 4 if a refetch is happening, even if there was an error before. If that's not the case in the latest version, could you try making a PR to fix it? 🙏

@msmfsd
Copy link
Author

msmfsd commented Apr 21, 2017

Thanks, will look to do this on the weekend.

@msmfsd
Copy link
Author

msmfsd commented Apr 21, 2017

@helfer I cloned the Apollo Client Error Template and networkStatus and refetch all work perfectly and as expected. I think that means the issue is not with react-apollo at all and is with apollo-client or possibly our app. As such can you close this issue. I will look at our app and if it is an issue with apollo-client I will log an issue there and link it to here.

Thanks for the help.

@helfer
Copy link
Contributor

helfer commented Apr 21, 2017

Thanks @msmfsd! I still think there could be an issue in Apollo Client, so don't exclude that as a possibility when investigating. Maybe it's just not that easy to reproduce.

@msmfsd
Copy link
Author

msmfsd commented Apr 24, 2017

@helfer you may be right, on refetch after a network status error i continue to see networkStatus not updated as expected. Have raised an issue on apollo-client: apollographql/apollo-client#1622

@msmfsd
Copy link
Author

msmfsd commented May 1, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants