query method
- QueryOptions<
Object?> options, { - RawClientOptions? raw,
- Exception onException()?,
Resolves a single query according to the QueryOptions specified and
returns a Future which resolves with the QueryResult or throws an
Exception.
Implementation
Future<QueryResult> query(
QueryOptions options, {
RawClientOptions? raw,
Exception Function(Map<String, dynamic>)? onException,
}) async {
final dio.Response posted = await post(
const RequestSerializer().serializeRequest(options.asRequest),
operationName: options.operationName,
onException: onException,
raw: raw,
);
if (posted.data['data'] == null) {
throw GraphQlException([GraphQLError(message: posted.data.toString())]);
}
final QueryResult query = QueryResult(
options: options,
source: QueryResultSource.network,
data: posted.data['data'],
);
GraphQlProviderExceptions.fire(query, onException);
return query;
}