I would like to be able to cancel fetchMore requests in these two scenarios:
When the Query component unmounts
Currently it seems like the initial query request will get cancelled when the component unmounts, but there is no way to cancel a request which was initiated with the fetchMore function. I think this would solve apollo-client issue #4114.
When the variables change
If the variables are changed while a fetchMore request is still in progress, the results from that fetchMore request are going to be completely useless; might as well just cancel the request. I think this would solve apollo-client issue #2813
@i8ramin I don't have any way to cancel the network request, but I did find a way to work around issue apollographql/apollo-client#2813
I just hold onto the query variables in a ref, then in the updateQuery function i do a deep comparison between the fetchMore variables and the current query variables
For the "when the Query component unmounts" scenario, it would be great if we could at least not get an error thrown when this happens. I don't necessarily care if the request gets cancelled (which doesn't look to be possible with fetch), I just don't want an error in my logs for an issue that doesn't actually impact the user.
@hwillson Thank you for checking in! I don't think this is as big of a problem with modern-day apollo client, but it's still something which I feel would make sense to implement eventually. Currently, if a query is mounted and then unmounted the network request will be canceled. But if a query is unmounted after changing the variables or calling fetchMore, the request will not be canceled. To me this feels inconsistent and confusing, but doesn't really cause any problems so it's not super important that it get solved. Neither of the issues I referenced in the original description (apollographql/apollo-client#4114 and apollographql/apollo-client#2813) are a problem for me anymore.
(I'm currently on @email@example.com so please excuse me if anything I stated above is no longer true in the latest version)