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

Abort pending request #969

Open
igaloly opened this issue Apr 30, 2020 · 3 comments
Open

Abort pending request #969

igaloly opened this issue Apr 30, 2020 · 3 comments

Comments

@igaloly
Copy link

igaloly commented Apr 30, 2020

The problem
There's no ability to cancel/abort a request that is pending and hasn't resolved yet

Use case

  • The user selected some parameters and the fetch began.
  • The user regretted his choice.
  • The user changed the parameters and another fetch began.
  • The second fetch resolved and data is displaying, the user is happy.
  • First fetch resolved, and because it was heavier, it took a longer time
  • The old unwanted data is being displayed, the user is sad.

Possible solutions
https://github.com/apollographql/apollo-feature-requests/issues/40#issuecomment-554561836
Works, but

  • You need to generate id yourself so that you will know what's the id of the current fetch
  • You need you to use methods without an abstraction, that it seems like, are not intended to be used by the end-user ( generateQueryId, fetchQuery, stopQuery etc )

apollographql/apollo-client#4150 (comment)
Works, but

  • You need to use a method, it seems like, not in the way it intended to be used
  • You need to promisify the subscribe and generally, work in a completely different way compared to simple query / mutation

Thoughts
It seems like the first solution is much more suitable, but a good abstraction should be implemented

@Akryum
Copy link
Member

Akryum commented Apr 30, 2020

vue-apollo doesn't handle making requests, it's apollo-client itself.

@igaloly
Copy link
Author

igaloly commented May 1, 2020

I understand.
But there is already such a capability implemented by apollo-client.
The problem is that there's no appropriate abstraction for this in vue-apollo's side.
We need to be able to the get the queryId of a pending query by its name ( or any other way ), and a method such as 'stopQuery' that'll get the id and will kill it.

@igaloly
Copy link
Author

igaloly commented May 10, 2020

@Akryum
Also, what do you think about the implementation of canceling pending requests when the component destroyed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants