getSingleOrder method

Future getSingleOrder(
  1. String id
)

Implementation

Future getSingleOrder(String id) async {
  GraphQLClient _client = graphQLConfiguration.clientToQuery();

  var orderGql = """
           query getOrderById(\$id: String) {
            getOrderById(id: \$id) {
              _id
              orderDate
              orderId
              bookingId
              shippingFees
              returnReason
              returnRejectionReason
              cancellationReason
              paymentMode
              checkPackage
              imageUrl
              paymentStatus
              orderStatus
              orderType
              history {
                action
                type
                customerView
                date
                __typename
              }
              user {
                userId
                __typename
              }
              price {
                totalPrice
                totalGstPrice
                totalWithOutGstPrice
                totalWithOutSCGstPrice
                totalMrp
                shippingPrice
                shippingGstPrice
                shippingCgstPrice
                shippingSgstPrice
                resellerPrice
                __typename
              }
              billingAddress {
                contactName
                companyName
                emailId
                mobileNumber
                address
                city
                state
                pincode
                __typename
              }
              shippingAddress {
                contactName
                companyName
                emailId
                mobileNumber
                address
                city
                state
                pincode
                __typename
              }
              user {
                contactName
                mobileNumber
                emailId
                userId
                __typename
              }
              orderProducts {
                _id
                productName
                imageId
                productId
                skuId
                productDescription
                type
                isMultiple
                category {
                  _id
                  categoryName
                  __typename
                }
                brand {
                  _id
                  brandName
                  __typename
                }
                attribute {
                  fieldName
                  fieldValue
                  colorCode
                  __typename
                }
                price {
                  mrp
                  sellingPrice
                  discount
                  totalPrice
                  gstLabelName
                  withOutGstPrice
                  sgstLabelName
                  cgstLabelName
                  totalSgst
                  totalCgst
                  withOutSCGstPrice
                  totalGst
                  __typename
                }
                totalPieces
                qty
                imageUrl
                skuIds {
                  sku
                  imageId
                  styleCode
                  skuId
                  attribute {
                    fieldName
                    fieldValue
                    colorCode
                    __typename
                  }
                  category {
                    _id
                    categoryName
                    __typename
                  }
                  brand {
                    _id
                    brandName
                    __typename
                  }
                  productDimension
                  packingDimension
                  weight
                  productId
                  type
                  isMultiple
                  productName
                  imageUrl
                  productDescription
                  price {
                    mrp
                    sellingPrice
                    discount
                    totalPrice
                    gstLabelName
                    withOutGstPrice
                    sgstLabelName
                    cgstLabelName
                    totalSgst
                    totalCgst
                    withOutSCGstPrice
                    totalGst
                    __typename
                  }
                  qty
                  __typename
                }
                children {
                  _id
                  productId
                  imageId
                  productName
                  productDescription
                  productName
                  productDescription
                  category {
                    _id
                    categoryName
                    __typename
                  }
                  brand {
                    _id
                    brandName
                    __typename
                  }
                  attribute {
                    fieldName
                    fieldValue
                    colorCode
                    __typename
                  }
                  totalPieces
                  price {
                    mrp
                    sellingPrice
                    discount
                    totalPrice
                    gstLabelName
                    withOutGstPrice
                    sgstLabelName
                    cgstLabelName
                    totalSgst
                    totalCgst
                    withOutSCGstPrice
                    totalGst
                    __typename
                  }
                  qty
                  imageUrl
                  skuIds {
                    skuId
                    sku
                    imageId
                    styleCode
                    attribute {
                      fieldName
                      fieldValue
                      colorCode
                      __typename
                    }
                    imageUrl
                    category {
                      _id
                      categoryName
                      __typename
                    }
                    brand {
                      _id
                      brandName
                      __typename
                    }
                    productDimension
                    packingDimension
                    weight
                    productName
                    productDescription
                    price {
                      mrp
                      sellingPrice
                      discount
                      totalPrice
                      gstLabelName
                      withOutGstPrice
                      sgstLabelName
                      cgstLabelName
                      totalSgst
                      totalCgst
                      withOutSCGstPrice
                      totalGst
                      __typename
                    }
                    qty
                    __typename
                  }
                  __typename
                }
                __typename
              }
              __typename
            }
          }


          """;

  final vble = {
    "id": id,
  };
  QueryResult result = await _client.query(QueryOptions(
    document: gql(orderGql),
    variables: vble,
    fetchPolicy: FetchPolicy.networkOnly,
  ));
  print(result);
  if (!result.hasException) {
    var singleOrderModel = result.data!['getOrderById'];

    if (singleOrderModel != null && singleOrderModel.length > 0) {
      singleOrder = getOrderByIdFromJson(singleOrderModel);
      return singleOrder;
    }
  }
  return singleOrder;
}