Optimizing a Query

Hello

When I tired to get my user quota, I got like

{
    "data": {
        "user_quota": {
            "credits_remaining": 1001,
            "max_available": 1001,
            "increment_rate": 15
        }
    }
}

In case if there are 200 products, having query like

query {
  products {
    request_id
    complexity
    data(first: 100) {
    pageInfo { 
        hasNextPage 
        hasPreviousPage 
        startCursor 
        endCursor 
      }
      edges {
        node {
          id
          legacy_id
          account_id
          name
          sku
          warehouse_products {
            warehouse_id
            on_hand
          }
        }
      }
    }
  }
}

1-100 at first connection
101-200 at second connection

In case if there are 200 orders, having query like

query {
shipments(date_from: "yyyy-mm-dd") {
request_id
complexity
data(first:10) {
  edges {
    node {
      id
      legacy_id
      order_id
      user_id
      warehouse_id
      pending_shipment_id
      address {
        name
        address1
        address2
        city
        state
        country
        zip
        phone
      }
      shipped_off_shiphero
      dropshipment
      created_date
      line_items(first: 10) {
        edges {
          node {
            line_item_id
            quantity
          }
        }
      }
      shipping_labels {
        id
        legacy_id
        account_id
        tracking_number
        carrier
        shipping_name
        shipping_method
        cost
        profile
        packing_slip
        warehouse
        insurance_amount
        carrier_account_id
        source
        created_date
      }
    }
  }
}
}
}

Are above queries are good practise to follow up?

@tomasw

Can you please give some suggestions?

@tomasw

Looking Forward to Hearing From You. Thanks!!!

Hi @Thiyagarajan1!
I apologize for my delayed response about this.
Absolutely, that will work, you will have to use pagination to navigate through the results:

Which is basically using the endCursor and then using it as after:...

If you are only interested on the On Hand you could also use the Inventory Snapshot

For the orders, you will need to do the pagination though.
Let me know if I could explain better or if there is anything else I could help with.
Thanks in advance!
Tom

Thank you!!!

Will let you know, If I need further clarification on this.

1 Like