Obtaining Shopify Returns in Bulk via GraphQL

Hi,

We are trying to import the returns from Shopify via Graphql.

https://shopify.dev/api/admin-graphql/2023-01/queries/return

According to the docs, the return id is required to download the return.

However, we cannot find any graphQL query to download bulk returns.

1 Like

Hey @j_michael_1 , the “returns” field can be queried through the orders object in our GraphQL Admin API, an example call would look something like this:

{
orders (first:30, reverse:true) {
edges {
node {
id
returns (first:10) {
edges {
node {
id
}
}
}
}
}
}
}

The example above would give you a list of return IDs associated with orders in a shop ordered by the newest descending to the last 30 orders. You could also integrate this call into a bulk query using our bulk operation mutations here if you needed to pull more than a few orders/return IDs at once (if you run into API rate limitations with the above example).

Hope this helps!

1 Like

Hi,

Need to confirm from support one thing
https://shopify.dev/api/admin-graphql/2023-01/objects/Order#queries .
What are the expected values for filter return_status?
https://shopify.dev/api/admin-graphql/2023-01/enums/ReturnStatus

We tried putting above status in query but seems like it is not filtering based on these statuses.
For example if we query using filter return_status:in_progress we are getting results (response below) but need to download completed returns as well, so need to conform from from your end what are the valid values for return_status filter in orders query?.

Thank you!

{
    "data": {
        "orders": {
            "pageInfo": {
                "endCursor": "eyJsYXN0X2lkIjo0MTkyOTM2Nzg4MDIwLCJsYXN0X3ZhbHVlIjoxNjY1NDk1NzgzMDAwfQ==",
                "hasNextPage": false,
                "hasPreviousPage": false,
                "startCursor": "eyJsYXN0X2lkIjozODgzMTMxMDQzODkyLCJsYXN0X3ZhbHVlIjoxNjQwMTgxNDU0MDAwfQ=="
            },
            "edges": [
                {
                    "cursor": "eyJsYXN0X2lkIjozODgzMTMxMDQzODkyLCJsYXN0X3ZhbHVlIjoxNjQwMTgxNDU0MDAwfQ==",
                    "node": {
                        "id": "gid://shopify/Order/3883131043892",
                        "createdAt": "2021-12-22T13:57:34Z",
                        "returns": {
                            "pageInfo": {
                                "hasNextPage": false
                            },
                            "edges": [
                                {
                                    "node": {
                                        "id": "gid://shopify/Return/562724916",
                                        "name": "#1056-R1",
                                        "status": "OPEN",
                                        "totalQuantity": 2,
                                        "returnLineItems": {
                                            "edges": [
                                                {
                                                    "node": {
                                                        "id": "gid://shopify/ReturnLineItem/1011875892",
                                                        "customerNote": null,
                                                        "quantity": 1,
                                                        "refundableQuantity": 1,
                                                        "refundedQuantity": 0,
                                                        "returnReason": "UNKNOWN",
                                                        "returnReasonNote": "",
                                                        "totalWeight": {
                                                            "unit": "POUNDS",
                                                            "value": 1.1875
                                                        }
                                                    }
                                                },
                                                {
                                                    "node": {
                                                        "id": "gid://shopify/ReturnLineItem/1011908660",
                                                        "customerNote": null,
                                                        "quantity": 1,
                                                        "refundableQuantity": 1,
                                                        "refundedQuantity": 0,
                                                        "returnReason": "SIZE_TOO_SMALL",
                                                        "returnReasonNote": "",
                                                        "totalWeight": {
                                                            "unit": "POUNDS",
                                                            "value": 1.9994
                                                        }
                                                    }
                                                }
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                },
                {
                    "cursor": "eyJsYXN0X2lkIjo0MTkyOTM2Nzg4MDIwLCJsYXN0X3ZhbHVlIjoxNjY1NDk1NzgzMDAwfQ==",
                    "node": {
                        "id": "gid://shopify/Order/4192936788020",
                        "createdAt": "2022-10-11T13:43:03Z",
                        "returns": {
                            "pageInfo": {
                                "hasNextPage": false
                            },
                            "edges": [
                                {
                                    "node": {
                                        "id": "gid://shopify/Return/562757684",
                                        "name": "#1062-R1",
                                        "status": "OPEN",
                                        "totalQuantity": 2,
                                        "returnLineItems": {
                                            "edges": [
                                                {
                                                    "node": {
                                                        "id": "gid://shopify/ReturnLineItem/1011941428",
                                                        "customerNote": null,
                                                        "quantity": 1,
                                                        "refundableQuantity": 1,
                                                        "refundedQuantity": 0,
                                                        "returnReason": "SIZE_TOO_LARGE",
                                                        "returnReasonNote": "",
                                                        "totalWeight": {
                                                            "unit": "POUNDS",
                                                            "value": 1.1875
                                                        }
                                                    }
                                                },
                                                {
                                                    "node": {
                                                        "id": "gid://shopify/ReturnLineItem/1011974196",
                                                        "customerNote": null,
                                                        "quantity": 1,
                                                        "refundableQuantity": 1,
                                                        "refundedQuantity": 0,
                                                        "returnReason": "SIZE_TOO_SMALL",
                                                        "returnReasonNote": "",
                                                        "totalWeight": {
                                                            "unit": "POUNDS",
                                                            "value": 1.9994
                                                        }
                                                    }
                                                }
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                }
            ]
        }
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 662,
            "actualQueryCost": 22,
            "throttleStatus": {
                "maximumAvailable": 1000.0,
                "currentlyAvailable": 978,
                "restoreRate": 50.0
            }
        }
    }
}

Anyone knows the answer to the above?