getCollectionByHandle method
Returns a collection by handle.
Implementation
Future<Collection> getCollectionByHandle(String collectionName,
{bool deleteThisPartOfCache = false}) async {
try {
final WatchQueryOptions _options = WatchQueryOptions(
document: gql(getFeaturedCollectionQuery),
variables: {'query': collectionName});
final QueryResult result = await _graphQLClient!.query(_options);
checkForError(result);
if (deleteThisPartOfCache) {
_graphQLClient!.cache.writeQuery(_options.asRequest, data: {});
}
return Collections.fromGraphJson(result.data!['collections'])
.collectionList[0];
} catch (e) {
log(e.toString());
}
return Collection.fromGraphJson({});
}