mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-11-02 23:17:17 +00:00
26 lines
596 B
Dart
26 lines
596 B
Dart
|
import 'package:graphql_flutter/graphql_flutter.dart';
|
||
|
|
||
|
abstract class ApiMap {
|
||
|
Future<GraphQLClient> getClient() async {
|
||
|
final httpLink = HttpLink(
|
||
|
'https://api.$rootAddress/graphql',
|
||
|
);
|
||
|
|
||
|
final Link graphQLLink = isWithToken
|
||
|
? AuthLink(
|
||
|
getToken: () async => authToken,
|
||
|
).concat(httpLink)
|
||
|
: httpLink;
|
||
|
|
||
|
return GraphQLClient(
|
||
|
cache: GraphQLCache(),
|
||
|
link: graphQLLink,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
abstract final String? rootAddress;
|
||
|
abstract final bool hasLogger;
|
||
|
abstract final bool isWithToken;
|
||
|
abstract final String authToken;
|
||
|
}
|