react-apollo-hooks
react-apollo-hooks copied to clipboard
fix refetch after error
fixes #74
@trojanowski any chance of merging and releasing this? 🙏 It fixes the error I'm seeing in our app 🙂
Could you add a unit test for it? To ensure that it won't be back after #134 is merged.
@trojanowski a test case has been added but I think it's a little ugly. the other approach that came to my mind was to expose refetch in Tasks via useImperativeHandle. please let me know how can I make it better
We tried this PR in our project and it works (fixes the problem), but there's one minor issue that could be fixed probably:
Right now, loading is always false, even when that refetch is in progress. Ideally, we should be informed about the loading change when refetch is being started.
Buut we can leave it as a separate issue and merge it PR in the meantime anyways ;]
loading should not be true when refetching, you should check if networkStatus is 4: https://www.apollographql.com/docs/react/api/react-apollo/#datanetworkstatus
Oh, okay. Well, in that case, the networkStatus isn't being updated, when refetch() is done after an error occurs.
See the following log:

Current outcome of networkStatus in the above scenario:
- loading
- failed
- ready
Expected outcome:
- loading
- failed
- refetch
- ready
Any update on this PR? Would be really great to see this merged.
you should probably use @apollo/react-hooks
you should probably use @apollo/react-hooks
I started using it as well, but I really really miss the elegance and ease of use of Suspense.
I understand. However @apollo/react-hooks is in beta currently and I wouldn't want to move to that library before it's stable.
Is there something missing in this PR or could it be merged as-is? As @huidini mentioned, using Suspense might still be a feature only this library has.
@amannn @apollo/react-hooks 3.0.0 released about an hour ago
https://github.com/apollographql/react-apollo/releases/tag/%40apollo%2Freact-hooks%403.0.0
@sijad Oh wow, what a coincidence 🙂. Thanks!