getProductList method
Implementation
Future getProductList(
String categoryLink, int page, int limit, List filter) async {
GraphQLClient _client = graphQLConfiguration.clientToQuery();
var productListGql = """
query getProductList(
\$categoryLink: String
\$page: Int
\$limit: Int
\$filter: [FilterAttribute]
) {
getProductList(
categoryLink: \$categoryLink
page: \$page
limit: \$limit
filter: \$filter
) {
product {
_id
productId
name
description
imageId
type
moq
isOutofstock
isMultiple
price {
sellingPrice
mrp
discount
minPrice
maxPrice
type
isSamePrice
__typename
}
images {
imageName
position
__typename
}
__typename
}
currentPage
totalPages
count
__typename
}
}
""";
final vble = {
"categoryLink": categoryLink,
"page": page,
"limit": limit,
"filter": filter
};
QueryResult result = await _client.query(QueryOptions(
document: gql(productListGql),
variables: vble,
fetchPolicy: FetchPolicy.networkOnly,
));
if (!result.hasException) {
var categoryPack = result.data!['getProductList'];
if (categoryPack != null && categoryPack.length > 0) {
categoryPackWithSet = productListFromJson(categoryPack);
}
return categoryPackWithSet;
}
return categoryPackWithSet;
}