48 lines
1.2 KiB
Dart
48 lines
1.2 KiB
Dart
|
import 'package:flutter/foundation.dart';
|
||
|
import 'package:graphql/client.dart';
|
||
|
|
||
|
final client = GraphQLClient(
|
||
|
link: _loggerLink.concat(HttpLink("http://localhost:4444/graphql")),
|
||
|
cache: GraphQLCache(store: null),
|
||
|
defaultPolicies: DefaultPolicies(
|
||
|
query: Policies(
|
||
|
fetch: FetchPolicy.noCache,
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
|
||
|
// final client = GraphQLClient(
|
||
|
// link: HttpLink("http://192.168.217.150:4444/graphql"),
|
||
|
// cache: GraphQLCache(store: null),
|
||
|
// defaultPolicies: DefaultPolicies(
|
||
|
// query: Policies(
|
||
|
// fetch: FetchPolicy.noCache,
|
||
|
// ),
|
||
|
// ),
|
||
|
// );
|
||
|
|
||
|
class LoggerLink extends Link {
|
||
|
@override
|
||
|
Stream<Response> request(
|
||
|
Request request, [
|
||
|
NextLink? forward,
|
||
|
]) {
|
||
|
Stream<Response> response = forward!(request).map((Response fetchResult) {
|
||
|
final ioStreamedResponse = fetchResult.context.entry<HttpLinkResponseContext>();
|
||
|
if (kDebugMode) {
|
||
|
print("Request: ${request.toString()}");
|
||
|
print("Response:${ioStreamedResponse?.toString() ?? "null"}");
|
||
|
}
|
||
|
return fetchResult;
|
||
|
}).handleError((error) {
|
||
|
throw error;
|
||
|
});
|
||
|
|
||
|
return response;
|
||
|
}
|
||
|
|
||
|
LoggerLink();
|
||
|
}
|
||
|
|
||
|
final _loggerLink = LoggerLink();
|