request method
Future<Map>
request(
- JsonQuery query, {
- TransactionHeaders? headers,
- Transaction? transaction,
override
Sends a request to the engine.
queryis the query to be sent to the engine.headersare the headers to be sent with the request.transactionis the transaction to be used for the request.
Implementation
@override
Future<Map> request(
JsonQuery query, {
TransactionHeaders? headers,
Transaction? transaction,
}) async {
headers ??= TransactionHeaders();
await start();
if (transaction != null) {
headers.set('x-transaction-id', transaction.id);
}
final response = await fetch(
_endpoint,
headers: headers,
body: query.toJson(),
method: 'POST',
);
final result = await response.json();
return switch (result) {
{'data': final Map data} => deserializeJsonResponse(data),
{'errors': final Iterable errors} => throwErrors(errors),
_ => throw PrismaClientUnknownRequestError(
message: json.encode(result),
),
};
}