stream<T, U extends JsonSerializable> method

Stream<GraphQLResponse<T>> stream<T, U extends JsonSerializable>(
  1. GraphQLQuery<T, U> query, {
  2. Context context = const Context(),
})

Streams a GraphQLQuery, returning a typed response stream.

Implementation

Stream<GraphQLResponse<T>> stream<T, U extends JsonSerializable>(
  GraphQLQuery<T, U> query, {
  Context context = const Context(),
}) {
  final request = Request(
    operation: Operation(
      document: query.document,
      operationName: query.operationName,
    ),
    variables: query.getVariablesMap(),
    context: context,
  );

  return _link.request(request).map((response) => GraphQLResponse<T>(
        data: response.data == null ? null : query.parse(response.data ?? {}),
        errors: response.errors,
        context: response.context,
      ));
}