tstor/ui/lib/api/client.dart
royalcat d8ee8a3a24
All checks were successful
docker / build-docker (linux/amd64) (push) Successful in 1m34s
docker / build-docker (linux/386) (push) Successful in 1m37s
docker / build-docker (linux/arm64/v8) (push) Successful in 7m37s
docker / build-docker (linux/arm64) (push) Successful in 7m44s
docker / build-docker (linux/arm/v7) (push) Successful in 8m12s
update
2024-04-24 20:36:33 +03:00

47 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();