Throttling not working properly

I tried to query a list of orders with filter “first: 10” using GraphQl public api but eventually it gave me the throttling error as mentioned below.

{
“errors”: [
{
“code”: 30,
“message”: “There are not enough credits to perfom the requested operation, which requires 1101 credits, but the are only 1001 left. In 7 seconds you will have enough credits to perform the operation”,
“operation”: “orders”,
“request_id”: “5f71c1132632f4492ba27f9b”,
“required_credits”: 1101,
“remaining_credits”: 1001,
“time_remaining”: “7 seconds”
}
],
“data”: {
“orders”: null
}
}

Then I waited for 7 seconds as mentioned in response and tried again but came up with the same error again. Can you please help me to understand this? We have a production deadline ahead so expecting the reply very soon.

Hi @Mahesh12794
Welcome to the community!
The reason you are seeing that message is that users are given 1001 credits, and every second, 15 credits are restored (this is the increment_rate), but no operation can exceed 1001 credits.
In your case, the cost of the operation is 1101.

The way you can lowe down that complexity is by using the pagination and the first filter also in the line items connection, otherwise, it will default to 100, causing the complexity to spike to 1101

Something like this:

query {
  orders {
    request_id
    complexity
    data(first: 10) {
      pageInfo {
        hasNextPage
        hasPreviousPage
        startCursor
        endCursor
      }
      edges {
        node {
          id
          legacy_id
          order_number
          partner_order_id
          shop_name
          fulfillment_status
          order_date
          total_tax
          subtotal
          total_discounts
          total_price
          auto_print_return_label
          custom_invoice_url
          account_id
          email
          profile
          packing_note
          required_ship_date
          flagged
          saturday_delivery
          ignore_address_validation_errors
          priority_flag
          source
          third_party_shipper {
            zip
            account_number
            country
          }
          gift_invoice
          order_history {
            created_at
            information
            user_id
          }
          allow_partial
          require_signature
          adult_signature_required
          alcohol
          expected_weight_in_oz
          insurance
          insurance_amount
          currency
          has_dry_ice
          allocation_priority
          allow_split
          shipments {
            id
            order_id
            warehouse_id
            pending_shipment_id
            delivered
            refunded
            completed
            shipping_labels {
              shipment_id
              order_id
              status
              tracking_number
              order_number
              carrier
              shipping_name
              shipping_method
            }
          }
          line_items(first: 10) {
            pageInfo {
              hasNextPage
              hasPreviousPage
              startCursor
              endCursor
            }
            edges {
              node {
                id
                sku
                quantity
                quantity_allocated
                quantity_pending_fulfillment
                backorder_quantity
                promotion_discount
                fulfillment_status
              }
            }
          }
        }
      }
    }
  }
}

Let me know if this doesn’t help or I could explain better.
Thanks in advance!
Tom