-
Notifications
You must be signed in to change notification settings - Fork 786
refetch() does not update loading to true #321
refetch() does not update loading to true #321
Comments
I think this is a docs issue, I think we changed this a little while back. |
Maybe there should be a way to differentiate between initial loading (where you just show a loading spinner) and incremental loading (where you also want to keep the current content in addition to the loading indicator)? |
@SachaG I think |
@helfer you're right, I was using an older version of Apollo that didn't have it. |
Hi! Thanks! |
I just gave @PascalHelbig's repro a quick check, swapping
If I instead change
The component never receives any props to indicate that a query is in flight. |
Aha, I might have found a workaround / solution: there is a With that option set, I get this output:
This is workable, but definitely surprising behavior that definitely needs to be better documented and possibly revisited. Some specific feedback of things that are surprising to me:
|
+1 |
This is really just a docs issue, so we should fix it there. |
I have this problem too. Whenever I make a call to |
We hit the same problem this time with The only workaround is to use I have submitted a PR with a small documentation change in the docs that addresses this. |
Which version of Apollo Client are folks running? |
I'm on |
Mine is:
|
any solution to this? |
@aikonplus the "solution" is to pass Loading actually changes to true whenever a refetch happens, but unless |
Sorry to bug you on, well, a closed bug, but how does one pass query options to |
You can't. It wouldn't make sense to pass most options anyway, because |
Wouldn't a more sane behavior be to set the I mean, imagine you have two buttons: Start/Stop, and a "loading..." indicator. On first view, you'll see "loading..." and then the Start button. Adding a |
@helfer The
Output:
After
And there's no more output after the request was completed.
|
Any solution for this? I have the same problem |
Shouldn't this ticket be reopened as the feature does not work as expected, aka. no changes in |
@eskimoblood I am having the same issue and I think that apollographql/apollo-client#1263 apollographql/apollo-client#1622 is also related to this problem. We should probably create a new issue for this with a 2.0 prefix. What is your opinion? Edit: Seems like the promise returned by Edit 2: When using I will also try to take a look at the code on the weekend. |
Any response from the maintainers? |
I don't know if anyone is still having issues with this, but I solved it by changing my |
Im still having this issue, and I set the |
Why is this issue closed? :/ I still have this problem! |
I'm using the HOC approach and it also doesn't work (refetch is triggered by another component).
|
Same issue, seems quite fundamental to me too. |
apollographql/apollo-client#4992 may help solve this. If anyone can provide an up-to-date reproduction, I can verify that. Thanks! |
I stumbled upon this issue within 5 minutes of trying out It only fails to rerender the component with From a product/user perspective, this means the following: If the user is given a retry button after fetching has failed (several times), and the user then clicks the button: There is simply no way of informing the user that a request is actually being retried. If it fails again, it looked like nothing ever happened.This would create pretty big UX issues in a lot of frontends.
|
@kasvtv sorry to hear that this is still an issue for you. Could you provide a codesandbox.io or github repo that shows this problem? I really want to fix this bug! |
@jasonpaulos |
I am trying to get apollographql/apollo-client#4992 merged into |
Wow this is quite similar to #2177 i.e. issue closed/ignored even though it persists, and also related to network status changes. |
Thank you very much for apollographql/apollo-client#4992 @jasonpaulos! We'll prioritize a release of Apollo Client with those changes included, so this issue will be fixed in RA very shortly. |
1. It prevents the `onError` callback from unnecessarily being called multiple times in a row. 2. It migrates all peer and dev deps to use `apollo-client` 2.6.4. Apollo Client 2.6.4 provides a fix for last result error tracking (apollographql/apollo-client@c44e821), which fixes the long standing React Apollo issue of `refetch` not setting `loading` state properly. Calling `refetch` will now first set `loading` to `true`. These fixes are bundled together, as verifying that `onError` is working properly requires being able to make sure results after a refetch that don't have an error, are handled properly. Fixes #3331. Fixes #3287. Fixes #2559. Fixes #321. (and probably fixes others!)
) * This commit helps address 2 main issues: 1. It prevents the `onError` callback from unnecessarily being called multiple times in a row. 2. It migrates all peer and dev deps to use `apollo-client` 2.6.4. Apollo Client 2.6.4 provides a fix for last result error tracking (apollographql/apollo-client@c44e821), which fixes the long standing React Apollo issue of `refetch` not setting `loading` state properly. Calling `refetch` will now first set `loading` to `true`. These fixes are bundled together, as verifying that `onError` is working properly requires being able to make sure results after a refetch that don't have an error, are handled properly. Fixes #3331. Fixes #3287. Fixes #2559. Fixes #321. (and probably fixes others!) * Changelog update * Silence extra CI warnings to troubleshoot test issues
This still occurs on v2.6.8 for me. I think i have spent an honest 4 hours trying to fix this bug where
|
ApolloClient v2.6.3 |
If you're using React, the new apollo hooks |
@Dajust do you mean for |
I fixed this issue by adding
However, it causes |
This solution works but is it possible not to trigger loading on fetchMore ? |
@EdmundMai Doesn't work for me (@apollo/client 3.0.0-beta.50), the loading is false when I call refetch. Doesn't work on 3.0.0-rc.2 too. Also the
and then I call |
I'm seeing the same behavior as @EllaSharakanski, using [email protected]. If I remove |
For anyone who wants to have different loadings on fetchMore and refetch, watch the networkStatus as it has value of 3 on fetchMore and 4 on refetch. |
Steps to Reproduce
Buggy Behavior
When I call
props.data.refetch()
,props.data.loading
is stillfalse
.Expected Behavior
I thought it would change loading to
true
.From docs:
Version
The text was updated successfully, but these errors were encountered: