getCollectionByHandle method

  1. @Deprecated('Use [getCollectionById]')
Future<Collection> getCollectionByHandle(
  1. String collectionName
)

Returns a collection by handle.

Implementation

@Deprecated('Use [getCollectionById]')
Future<Collection> getCollectionByHandle(
  String collectionName,
) async {
  try {
    final WatchQueryOptions _options = WatchQueryOptions(
      document: gql(getFeaturedCollectionQuery),
      variables: {
        'query': collectionName,
        'country': ShopifyLocalization.countryCode,
      },
      fetchPolicy: ShopifyConfig.fetchPolicy,
    );
    final QueryResult result = await _graphQLClient!.query(_options);
    checkForError(result);
    return Collections.fromGraphJson(result.data!['collections'])
        .collectionList[0];
  } catch (e) {
    log(e.toString());
  }
  return Collection.fromGraphJson({});
}