GraphQL Paginated Calls with Query Parameters

I have a query where I pass in different values for the pagination limit, and it gives back different results.

I use the two fields in pageInfo, hasNextPage and endCursor, and if the results include hasNextPage equal to true, I pass in the value from endCursor as the variable for $cursor in the query. This is the query:

query ($numOrders: Int!, $cursor: String) {
orders(first: $numOrders, after: $cursor, query: “fulfillment_status:‘UNFULFILLED’ AND financial_status:‘PAID’ AND status:‘OPEN’”) {
nodes {
id
name
displayFulfillmentStatus
displayFinancialStatus
closed
note
}
pageInfo {
hasPreviousPage
hasNextPage
startCursor
endCursor
}
}
}

If I pass in $numOrders as 10, I get 7 total results, but the pageInfo for the last call (the only call in this case) gives back
“pageInfo” => %{
“endCursor” => nil,
“hasNextPage” => true,
“hasPreviousPage” => true,
“startCursor” => nil
}

If I pass in a limit of 20, I get 12 total results with thee pageInfo in the last call being

“pageInfo” => %{
“endCursor” => “eyJsYXN0X2lkIjo1MDc0MzA3NDgxNzk1LCJsYXN0X3ZhbHVlIjoxNjc3MjQ5NTY3MDAwfQ==”,
“hasNextPage” => false,
“hasPreviousPage” => true,
“startCursor” => “eyJsYXN0X2lkIjo0ODQ0MDgxNjc2NDgzLCJsYXN0X3ZhbHVlIjoxNjYyNTc4NjczMDAwfQ==”
}

This does not seem like a working combination of pageInfo in either case. Am I doing something wrong?

Using the rest api, I get back 14 results using the equivalent filters.

Hey @Print _simple,

This is an interesting one. Nothing stands out as incorrect with your query, so it’s strange that the limit of 10 would return the null results.

One thing you could try is using edges with your paginated query.

From there, it may help for us to have a look in to the store specific settings so reaching out through the support center would be help us look further.

  • Kyle G.

@ShopifyDevSup
Thanks for your reply.

I contacted Shopify support, but they need me to adhere to specific ‘support protocols’ before they can escalate the issue to the appropriate team. I provided them with the following details:

In general terms, what is the API action trying to do?
We’re trying to get a paginated result using a custom graphql query

What is the expected result, and what is happening instead?
The expected result is that the number of results per call should be equal to the limit we provide, and the results of the query should be consistent when providing different limits

When did this happen? Does it happen consistently or just sometimes?
This happens when we make a call to the graphql endpoint and the query is orders

Which app is making the API call?
The app making the call is Print Simple

Has it ever worked correctly?
No, it has never worked correctly

Is there a specific part of the official API docs that are being followed?
Yes, we are using the pagination part of the graphql api docs

Could you assist in escalating the issue to gain access to the store and verify there are no settings causing the unexpected results?

Thanks in advance.