getCollectionsByIds method
Returns a List of Collection
Implementation
Future<List<Collection>?> getCollectionsByIds(
List<String> idList,
) async {
try {
final WatchQueryOptions _options = WatchQueryOptions(
document: gql(getCollectionsByIdsQuery),
variables: {'ids': idList},
fetchPolicy: ShopifyConfig.fetchPolicy,
);
final QueryResult result = await _graphQLClient!.query(_options);
checkForError(result);
var newResponse = List.generate(result.data!['nodes']?.length ?? 0,
(index) => {"node": (result.data!['nodes'] ?? const {})[index]});
var tempCollection = {"edges": newResponse};
return Collections.fromGraphJson(tempCollection).collectionList;
} catch (e) {
log(e.toString());
}
return [Collection.fromJson({})];
}