query method

Future<QueryResult<Object?>> query(
  1. QueryOptions<Object?> options, {
  2. RawClientOptions? raw,
  3. Exception onException(
    1. Map<String, dynamic>
    )?,
})

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 {
  if (raw != null) {
    return await _transaction(options.operationName, () async {
      final QueryResult result = await (await _newClient(
        raw,
      )).query(options).timeout(timeout);
      GraphQlProviderExceptions.fire(result, onException);
      return result;
    });
  } else {
    return await _middleware(() async {
      return _transaction(options.operationName, () async {
        final QueryResult result = await _queryLimiter.execute(
          () async => await (await client).query(options).timeout(timeout),
        );
        GraphQlProviderExceptions.fire(result, onException);
        return result;
      });
    });
  }
}