getOrderList method

Future getOrderList(
  1. String userId,
  2. int pageNo,
  3. int limit
)

Implementation

Future getOrderList(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
              shippingFees
              _id
              __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.length > 0) {
      orderList = orderListFromJson(orderListModel);
      return orderList;
    }
  }
  return orderList;
}