-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling refetch fires off a network request when skip is true #8270
Comments
Yes please, seeing the same behaviour. @brainkim Do you want a reproduction made for this, or is it straight forward enough to rig up on your own? |
One thing you can possibly do is check whatever state you’re using for the skip property and checking that before calling |
This is exactly what I'm doing at the moment. That said, the current behavior is clearly broken even if we ignore the fact that it fires off a network request when skip is true (the data is never received by the hook even though a request was in flight and has completed). Plus the behavior was different in the previous minor version (it threw an error instead of firing off a request)... What's the point of versioning if things aren't getting fixed because someone might rely on a non-sensical/buggy behavior? |
@brainkim Thanks for the response! I can definitely do what you're suggesting, but I agree with @knedev42 That said I can understand your hesitance but I think the |
@knedev42 Oh I missed that part, was the behavior changed between 3.1 and 3.3? I guess I’m okay with changing the behavior then. |
@brainkim Coming back to this as the workaround isn't really possible for my usecase. The skip logic is complex and in a custom hook that does some other data fetching, and the refetch is called through a react Context which has no idea about all the skip logic or how to recreate it (nor should it). Anyway, all this to say: would love to see this fixed or at least know that it's on some kind of roadmap. |
@brainkim @hwillson Is there not a difference between
|
I don’t think it’s wise to distinguish This behavior will soon be reverted. The correct way to deal with |
Calling
refetch
ignores theskip: true
option for the query hook. The full config of the query hook is:Intended outcome:
Calling
refetch
whenskip
istrue
should not produce a network request.Actual outcome:
Calling
refetch
whenskip
istrue
produces a network request. While the request is in flight the loading state is false, when the data is fetched it's not rendered (not passed to the data prop). The reason why skip is true in this case is lack of certain variables, that would filter a large data set. There's a button on the page that can "refresh" the data, which calls therefetch
function. Previously (on v3.1.3) refetch was throwing an error, instead of firing off a network request (which was also a bad behavior and was something that we handled in a weird way). It would be nice if it can just respect theskip
property and not do anything if it'strue
.Versions
npmPackages:
@apollo/client: ^3.3.19 => 3.3.19
The text was updated successfully, but these errors were encountered: