Created
March 20, 2024 13:42
-
-
Save zeienko-vitalii/d32f2609a6c4068499ac07d551172031 to your computer and use it in GitHub Desktop.
graphql_client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:ferry/ferry.dart'; | |
import 'package:gql_http_link/gql_http_link.dart'; | |
import 'package:simple_articles_app/utils/logger.dart'; | |
const String baseUrl = | |
'https://api-eu-central-1.graphcms.com/v2/ckl4xdv123tnhmkc/master'; | |
class GraphQlClient { | |
/// Initialises [_client] with setting cache store | |
factory GraphQlClient() { | |
_client ??= Client(link: HttpLink(baseUrl)); | |
return _singleton; | |
} | |
GraphQlClient._(); | |
static final GraphQlClient _singleton = GraphQlClient._(); | |
static Client? _client; | |
Client get client { | |
if (_client == null) { | |
debugLog('GraphQlClient.safeClient: client is null'); | |
} | |
return _client!; | |
} | |
void dispose() { | |
debugLog('GraphQlClient.dispose'); | |
_client?.dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment