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

Subscription stream transformer missing #755

Closed
vasilich6107 opened this issue Oct 26, 2020 · 3 comments · Fixed by #768
Closed

Subscription stream transformer missing #755

vasilich6107 opened this issue Oct 26, 2020 · 3 comments · Fixed by #768
Assignees
Labels
released on @beta released v4 Issue with a v4 library

Comments

@vasilich6107
Copy link
Contributor

vasilich6107 commented Oct 26, 2020

Describe the issue
Subscription stream minnsin transformer to transform error into query result object
https://github.com/zino-app/graphql-flutter/blob/beta/packages/graphql/lib/src/core/query_manager.dart#L68

In case if there is an error in request the subscription stream does not handle errors correctly to match the query flow.

In case of error simulation in tests

when(
        mockHttpClient.send(any),
      ).thenThrow(Error());

you'll get an error

package:gql_http_link/src/link.dart 157:7                      HttpLink._executeRequest
package:gql_http_link/src/link.dart 97:32                      HttpLink.request
===== asynchronous gap ===========================
dart:async                                                     _AsyncStarStreamController.addError
package:gql_http_link/src/link.dart                            HttpLink.request
===== asynchronous gap ===========================
dart:async                                                     _asyncErrorWrapperHelper
package:gql_link/src/link.dart 125:36                          _LinkChain.request.<fn>.<fn>
package:gql_link/src/link.dart 126:8                           _LinkChain.request
package:graphql/src/core/query_manager.dart 68:17              QueryManager.subscribe
===== asynchronous gap ===========================
dart:async                                                     _StreamImpl.listen
package:graphql_flutter_bloc/src/subscription/bloc.dart 87:42  SubscriptionBloc.mapEventToState
===== asynchronous gap ===========================
dart:async                                                     _StreamImpl.listen
package:bloc/src/bloc.dart 240:7                               Bloc._bindEventsToStates
package:bloc/src/bloc.dart 22:5                                new Bloc
package:graphql_flutter_bloc/src/subscription/bloc.dart 18:9   new SubscriptionBloc
test/subscription_test.dart 21:9                               new TestSubscriptionBloc
test/subscription_test.dart 49:30                              main.<fn>.<fn>

ServerException(originalException: Instance of 'Error', parsedResponse: null)

Expected behavior
Transforms error into QueryResult object for consistency.

Temp workaround

subscription = client.subscribe(event.options).handleError(Object error) {
    QueryResult queryResult = QueryResult(source: QueryResultSource.network);

    queryResult.exception = coalesceErrors(
      exception: queryResult.exception,
      linkException: translateFailure(error),
    );

    // do with query result whatever you need
  });
@micimize
Copy link
Collaborator

micimize commented Nov 9, 2020

closed by #768

@micimize micimize closed this as completed Nov 9, 2020
@HofmannZ
Copy link
Member

🎉 This issue has been resolved in version 4.0.0-beta.5 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@HofmannZ
Copy link
Member

🎉 This issue has been resolved in version 4.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released on @beta released v4 Issue with a v4 library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants