-
Notifications
You must be signed in to change notification settings - Fork 122
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
allow cancellation of call using dio cancellation #408
Conversation
Hello, thanks for the PR. It seems there is an issue with the CI, looks like a breaking change in one of the dependencies of multipack. I'll try to fix it. Support for cancellation in Dio is good, but is passing a signal cancel token for all requests of the link the right approach? You can only cancel the token once, right? I think a better solution would be to pass the cancel token via the context. Then the client code could either create a new cancel token for each request or re-use the same token for multiple requests if preferred. See e.g. https://github.com/gql-dart/gql/blob/master/links/gql_dio_link/lib/src/dio_link.dart#L312 class DioLinkCancelTokenContextEntry extends ContextEntry {
final CancelToken token;
...
} in DioLink: ...
final cancelToken = request.context.entry<DioLinkCancelTokenContextEntry>();
...
|
Makes sense. I have made the changes to push the cancellation token to the context entry. |
please update your branch from master to fix the ci issues |
done |
@@ -30,6 +31,7 @@ extension _CastDioResponse on dio.Response { | |||
class DioLink extends Link { | |||
/// Endpoint of the GraphQL service | |||
final String endpoint; | |||
// final dio.CancelToken? cancelToken; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls delete commented leftover code
@@ -66,8 +68,7 @@ class DioLink extends Link { | |||
|
|||
@override | |||
Stream<Response> request(Request request, [forward]) async* { | |||
final dio.Response<Map<String, dynamic>> dioResponse = | |||
await _executeDioRequest( | |||
final dio.Response<Map<String, dynamic>> dioResponse = await _executeDioRequest( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls run dart format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please delete the commented out code and run dart format
made the changes the source is properly formatted as per the diff |
Thanks, LGTM |
allow cancellation of call using dio cancellation