getUserOrderList method
Implementation
Future getUserOrderList(String userId, int pageNo, int limit) async {
GraphQLClient _client = graphQLConfiguration.clientToQuery();
var orderListGql = """
query getUserOrder(\$userId: String, \$pageNo: Int, \$limit: Int) {
getUserOrder(userId: \$userId, pageNo: \$pageNo, limit: \$limit) {
order {
orderId
orderDate
orderStatus
totalAmount
orderType
shippingFees
_id
price {
totalPrice
resellerPrice
__typename
}
__typename
}
currentPage
totalPages
count
__typename
}
}
""";
final vble = {"userId": userId, "pageNo": pageNo, "limit": limit};
QueryResult result = await _client.query(QueryOptions(
document: gql(orderListGql),
variables: vble,
fetchPolicy: FetchPolicy.networkOnly,
));
if (!result.hasException) {
var orderListModel = result.data!['getUserOrder'];
if (orderListModel != null && orderListModel['order'].length > 0) {
orderList = orderListFromJson(orderListModel);
return orderList;
}
}
return null;
}