onRequest method Null safety

  1. @override
Future onRequest(
  1. Request request,
  2. HasuraConnect hasuraConnect
)

Implementation

@override
Future onRequest(Request request, HasuraConnect hasuraConnect) async {
  try {
    final metric = FirebasePerformance.instance.newHttpMetric(
      request.url.replaceAll('_', '-'),
      HttpMethod.Post,
    );
    metric.requestPayloadSize = request.query.document.length;
    final size = request.query.document.indexOf('{');
    metric.putAttribute(
      'query',
      request.query.document.substring(0, size > 39 ? 39 : size),
    );
    _mapMetric[request.query.hashCode] = metric;
    await metric.start();
    // ignore: avoid_catches_without_on_clauses
  } catch (e, stackTrace) {
    debugPrintStack(
      label: e.toString(),
      stackTrace: stackTrace,
    );
  }
  return super.onRequest(request, hasuraConnect);
}