setConfig static method

void setConfig(
  1. String storefrontAccessToken,
  2. String storeUrl,
  3. String storefrontApiVersion, {
  4. Store? cacheStore,
})

Sets the config.

IMPORTANT: preferably call this inside the main function or at least before instantiating other Shopify classes.

Implementation

static void setConfig(
  String storefrontAccessToken,
  String storeUrl,
  String storefrontApiVersion, {
  Store? cacheStore,
}) {
  _storefrontAccessToken = storefrontAccessToken;
  _storeUrl = storeUrl;
  _storefrontApiVersion = storefrontApiVersion;
  _cacheStore = cacheStore;
  _graphQLClient = GraphQLClient(
    link: HttpLink(
      'https://$_storeUrl/api/$_storefrontApiVersion/graphql.json',
      defaultHeaders: {
        'X-Shopify-Storefront-Access-Token': _storefrontAccessToken!,
      },
    ),
    cache: GraphQLCache(
      store: _cacheStore,
    ),
  );
}