Skip to content
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

How do I cancel a fetchMore? #3360

Closed
panigrah opened this issue Apr 23, 2018 · 3 comments
Closed

How do I cancel a fetchMore? #3360

panigrah opened this issue Apr 23, 2018 · 3 comments

Comments

@panigrah
Copy link

I have a <Query> component with a fetchMore. I need to cancel the fetchMore if it has been initiated when the Query is restarted in my component. How can I do this?

thanks

@cronello
Copy link

I have a query getting data by category (categoryId as a param in options.variables)

  • each category can have many items so I need fetchMore for "infinit" scroll

Problem is when changing category while fetching more at the last category

  • updateQuery at fetchMore parameters gives items for the last category (but I get next/changed categoryId at variables params)
  • so I get items from next category but also mixed with items from last category (when the fetchMore resolves)

If I can stop/cancel the fetchMore request there will be just the items for the next categoryId

@jackh726
Copy link

I don't think there is a way to cancel a fetchMore directly, but I think if you keep track of the canceled status, and just return the previous result, that would simulate it.

However, a fix for fetchMore receiving the wrong variables (#2499) may cause cancelling to be unnecessary. Even if you send a new query before the old fetchMore resolves, it shouldn't overwrite the new query. Really, that fetchMore data is/should be still "valid" and could be cached for future queries.

@hwillson
Copy link
Member

To help provide a more clear separation between feature requests / discussions and bugs, and to help clean up the feature request / discussion backlog, Apollo Client feature requests / discussions are now being managed under the https://github.com/apollographql/apollo-feature-requests repository.

This feature request / discussion will be closed here, but anyone interested in migrating this issue to the new repository (to make sure it stays active), can click here to start the migration process. This manual migration process is intended to help identify which of the older feature requests are still considered to be of value to the community. Thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants