getCollectionByHandle method
- @Deprecated('Use [getCollectionById]')
- String collectionName, {
- List<
MetafieldIdentifier> ? metafields,
Returns a collection by handle.
Implementation
@Deprecated('Use [getCollectionById]')
Future<Collection> getCollectionByHandle(
String collectionName, {
List<MetafieldIdentifier>? metafields,
}) async {
try {
final WatchQueryOptions _options = WatchQueryOptions(
document: gql(getFeaturedCollectionQuery),
variables: {
'query': collectionName,
'country': ShopifyLocalization.countryCode,
'metafields': metafields != null
? metafields.map((e) => e.toJson()).toList()
: [],
},
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({});
}