A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hi,
I want to display the list of returns for a store in a table with pagination control. As I understand, this requires using the Shopify GraphQL API to get returns.
I know returns can be queried under orders, simple example (I've omitted the cursor controls for simplicity):
{ orders (first:10) { edges { node { id returns (first:10) { edges { node { id } } } } } } }
But I want to display say 10 returns per paginated page and not every order has a return.
How do I add the condition that only orders that have at least 1 return line item should be returned in the query response?
Furthermore, since it seems that it is possible that an order can have more than 1 return, how can I ensure that for each GraphQL query I get exactly 10 return line items (assuming that there is another page of returns after the current cursor, the last page of course could have fewer items than the page size).
Solved! Go to the solution
This is an accepted solution.
Hi, Tokuhn
return_status I think this field you also could check to filter.
HI, there
I think you could filter all the order which has return. and then go on your logic. what do you think?
you could refer the GraphQL below:
{
orders (first:10,query: "financial_status:refunded") {
edges {
node {
id
}
}
}
}
Hi Eric-Han,
Thanks very much for your reply. That is helpful.
I added partially_refunded to the query and that is working, i.e.
query: "financial_status:refunded,partially_refunded"
I need to also get returns that are in progress though. This status does not appear in the list for financial_status likely since it applies to the return and not the order.
Any ideas on how to also get the returns that are in progress? I need to get all types of returns
This is an accepted solution.
Hi, Tokuhn
return_status I think this field you also could check to filter.
Hi Eric-HAN,
I think that provides what I was looking for. The Shopify GraphQL API is a bit strange though as you need to put returnStatus = "IN_PROGRESS" as you highlighted but the API response returns "OPEN" for the return object status instead of "IN_PROGRESS".
Thanks very much for your help with this!
hi Tokuhn,
can you please share with me the structure of the query.
thank you in advance.
Hi WKS,
The general query is of this form:
{
orders(first: 10, query: "returnStatus:IN_PROGRESS,RETURNED") {
nodes {
returns(first: 10) {
nodes {
id
status
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
You can add/change other return statuses as needed.