Vue-apollo: Abort pending request

Created on 30 Apr 2020  路  3Comments  路  Source: vuejs/vue-apollo

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 )

https://github.com/apollographql/apollo-client/issues/4150#issuecomment-500127694
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

enhancement

Most helpful comment

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

All 3 comments

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

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.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AruXc picture AruXc  路  4Comments

jsrkstr picture jsrkstr  路  3Comments

alx13 picture alx13  路  4Comments

sadhakbj picture sadhakbj  路  3Comments

ais-one picture ais-one  路  4Comments