request method
Future<GraphQLResult>
request({
- required String query,
- QueryEngineRequestHeaders? headers,
- TransactionInfo? transaction,
override
Requests a query execution.
Implementation
@override
Future<GraphQLResult> request({
required String query,
QueryEngineRequestHeaders? headers,
TransactionInfo? transaction,
}) async {
await start();
logger.emit(Event.query, QueryPayload(query: query));
final url = resolveRequestEndpoint();
final wrappedHeaders =
headersWrapper(headers: [this.headers, headers], info: transaction);
final body = stringifyQuery(query);
/// Create a retry function.
Future<GraphQLResult> fn(void Function(Uri) logger) async {
logger(url);
final response =
await http.post(url, headers: wrappedHeaders, body: body);
final json =
(convert.json.decode(convert.utf8.decode(response.bodyBytes)) as Map)
.cast<String, dynamic>();
_tryThrowPrismaException(json);
_tryThrowExceptionFromStatusCode(response.statusCode);
return GraphQLResult.fromJson(json);
}
return withRetry<GraphQLResult>(fn, gerund: 'querying');
}