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

fix refetch after error

Open sijad opened this issue 6 years ago • 12 comments

fixes #74

sijad avatar Apr 24 '19 07:04 sijad

@trojanowski any chance of merging and releasing this? 🙏 It fixes the error I'm seeing in our app 🙂

SimenB avatar May 09 '19 14:05 SimenB

Could you add a unit test for it? To ensure that it won't be back after #134 is merged.

trojanowski avatar May 09 '19 20:05 trojanowski

@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

sijad avatar May 13 '19 06:05 sijad

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 ;]

jack-sf avatar Jun 03 '19 13:06 jack-sf

loading should not be true when refetching, you should check if networkStatus is 4: https://www.apollographql.com/docs/react/api/react-apollo/#datanetworkstatus

SimenB avatar Jun 03 '19 13:06 SimenB

Oh, okay. Well, in that case, the networkStatus isn't being updated, when refetch() is done after an error occurs.

See the following log:

image

Current outcome of networkStatus in the above scenario:

  • loading
  • failed
  • ready

Expected outcome:

  • loading
  • failed
  • refetch
  • ready

jack-sf avatar Jun 04 '19 09:06 jack-sf

Any update on this PR? Would be really great to see this merged.

amannn avatar Aug 05 '19 14:08 amannn

you should probably use @apollo/react-hooks

sijad avatar Aug 05 '19 14:08 sijad

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.

huidini avatar Aug 05 '19 14:08 huidini

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 avatar Aug 06 '19 14:08 amannn

@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 avatar Aug 06 '19 14:08 sijad

@sijad Oh wow, what a coincidence 🙂. Thanks!

amannn avatar Aug 06 '19 14:08 amannn