execute<T, U extends JsonSerializable> method

Future<GraphQLResponse<T>> execute <T, U extends JsonSerializable>(
  1. GraphQLQuery<T, U> query
)

Executes a GraphQLQuery, returning a typed response.

Implementation

Future<GraphQLResponse<T>> execute<T, U extends JsonSerializable>(
  GraphQLQuery<T, U> query,
) async {
  final request = Request(
    operation: Operation(
      document: query.document,
      operationName: query.operationName,
    ),
    variables: query.getVariablesMap(),
  );

  final response = await _link.request(request).first;

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