From 8dffcab30d28caab2b679ef5c5c99c2be3d3ea41 Mon Sep 17 00:00:00 2001 From: NaiJi Date: Mon, 19 Dec 2022 22:53:07 +0400 Subject: [PATCH] chore: Rename and unify GraphQL logging classes --- lib/logic/api_maps/graphql_maps/api_map.dart | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/logic/api_maps/graphql_maps/api_map.dart b/lib/logic/api_maps/graphql_maps/api_map.dart index 0f786417..02b9bc04 100644 --- a/lib/logic/api_maps/graphql_maps/api_map.dart +++ b/lib/logic/api_maps/graphql_maps/api_map.dart @@ -1,6 +1,3 @@ -// ignore_for_file: prefer_foreach - -import 'dart:async'; import 'dart:io'; import 'package:graphql_flutter/graphql_flutter.dart'; @@ -17,7 +14,7 @@ void _logToAppConsole(final T objectToLog) { ); } -class LoggingLink extends Link { +class RequestLoggingLink extends Link { @override Stream request( final Request request, [ @@ -28,7 +25,7 @@ class LoggingLink extends Link { } } -class LoggingResponseParser extends ResponseParser { +class ResponseLoggingParser extends ResponseParser { @override Response parseResponse(final Map body) { final response = super.parseResponse(body); @@ -61,12 +58,12 @@ abstract class ApiMap { final httpLink = HttpLink( 'https://api.$rootAddress/graphql', httpClient: ioClient, - parser: LoggingResponseParser(), + parser: ResponseLoggingParser(), ); final String token = _getApiToken(); - final Link graphQLLink = LoggingLink().concat( + final Link graphQLLink = RequestLoggingLink().concat( isWithToken ? AuthLink( getToken: () async => @@ -76,8 +73,8 @@ abstract class ApiMap { ); // Every request goes through either chain: - // 1. AuthLink -> HttpLink -> LoggingLink - // 2. HttpLink -> LoggingLink + // 1. RequestLoggingLink -> AuthLink -> HttpLink + // 2. RequestLoggingLink -> HttpLink return GraphQLClient( cache: GraphQLCache(),