How to Decrease Complexity of the querys

How to decrease complexity of the query.

I was call inventory_changes query but i got below error, i found query required 101 credit for single record (Particular SKU) , how to resolve this issue, please help

{
“errors”: [
{
“code”: 30,
“message”: “There are not enough credits to perfom the requested operation, which requires 101 credits, but the are only 0 credits left. You can execute queries up to that level of credits or wait 32 minutes until your quota is refreshed”,
“operation”: “inventory_changes”,
“request_id”: “5d71066ba584c602ef4c6fce”,
“required_credits”: 101,
“remaining_credits”: 0,
“time_remaining”: “32 minutes”
}
],
“data”: {
“inventory_changes”: null
}
}

Query : query{
inventory_changes(sku:“701980785238”){
complexity
data{

  edges{
    
    node{
      cycle_counted
      
     
    }
  }
}

}
}

Daniel,
Try adding first to the data and use hasNextPage to see if you need to retrieve more records. Without first the complexity defaults to 100.

For example:

{
  inventory_changes(sku: "701980785238") {
    complexity
    data(first: 10) {
      pageInfo {
        hasNextPage
      }
      edges {
        node {
          cycle_counted
        }
      }
    }
  }
}
1 Like

Thank you so much
I was try above solution and it decreasing the complexity

1 Like

Hi
How to get data for particular cursor value

Hi Daniel,
You could do it by adding cursor along with the node. For example:

{
  inventory_changes(sku: "701980785238") {
    complexity
    data(first: 10) {
      pageInfo {
        hasNextPage
      }
      edges {
        node {
          cycle_counted
        }
        cursor
      }
    }
  }
}

also, on the page info section you can also see first and last cursors, for example:

{
  inventory_changes(sku: "701980785238") {
    complexity
    data(first: 10) {
      pageInfo {
        hasNextPage
        hasPreviousPage
        startCursor
        endCursor
      }
      edges {
        node {
          cycle_counted
        }
      }
    }
  }
}

This is correct but i want to know how to use cursor value for search criteria to find data for one cursor value, there has any mechanism to pass cursor value in the query.

Absolutely!, if you need to specify a cursor you can do so by adding the cursor’s value it to data using after or before.
For the previous example, would be something like this:

{
      inventory_changes(sku: "701980785238") {
        complexity
        data(after:"YXJyYXljb25uZWN0aW9uOjk5") {
          pageInfo {
            hasNextPage
            hasPreviousPage
            startCursor
            endCursor
          }
          edges {
            node {
              cycle_counted
            }
          }
        }
      }
    }

This way it will now retrieve information after cursor: YXJyYXljb25uZWN0aW9uOjk5

A suggestion to keep in mind here is that cursors have a dynamic nature in pagination, this means that they might not always have the same value if the query or the data changes they also might change.

GraphQL Primer – Developer Resources | ShipHero