最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Shopify GraphQL Admin API - Empty Returns - Stack Overflow

programmeradmin3浏览0评论

Apologies for the long question but I wanted to include all of the various things we've tried.

TLDR: for some reasons, no API call lets us access a Shopify store's returns. The same API calls work for a different store, and different platforms are using the API to get returns out of this store, but nothing works for us on this store in particular.

  • We are querying Shopify's GraphQL Admin API for order returns, but the returns field always returns an empty array (edges: [], nodes: []).
  • We know for a fact that returns exist for some orders in our store.
  • We have verified that DataExport.io successfully retrieves return data from our store.
  • Refunds (order.refunds) return data correctly, but returns does not.
  • We have the correct read_returns API permission.

Debugging Steps We Have Tried

Step 1: Verified the returns Field Exists in GraphQL We ran the query:

graphql
{
    __type(name: "Order") {
        fields {
            name
        }
    }
}

This returned { name: "returns" }, (amongst others) confirming that returns is a valid field inside the Order object.

Conclusion: The API should support returns.

Step 2: Checked API Permissions

We ran:

graphql
query {
    currentAppInstallation {
        accessScopes {
            description
            handle
        }
    }
}

This confirmed that the app has the read_returns permission.

Conclusion: Lack of permissions is NOT the issue.

Step 3: Tried Fetching Returns for a Specific Order

We tested a query like this:

graphql
query GetOrderReturns {
    order(id: "gid://shopify/Order/5567623526582") {
        id
        returns(first: 50) {
            edges {
                node {
                    id
                    status
                }
            }
        }
    }
}

Result: { "returns": { "edges": [] } } → No returns, even though we know they exist.

Conclusion: Shopify is not returning return data inside order.returns.

Step 4: Verified refunds Returns Data

Since refunds and returns are different, we tested:

graphql
query {
    order(id: "gid://shopify/Order/5567123556582") {
        id
        refunds(first: 5) {
            edges {
                node {
                    id
                    totalRefundedSet {
                        shopMoney {
                            amount
                        }
                    }
                }
            }
        }
    }
}

Result: Refunds successfully returned data.

Conclusion: The API is working for refunds, but returns remains empty.

Step 5: Tested a More Comprehensive Query

We expanded our GraphQL request to ask for every possible return-related field:

graphql
query GetOrderReturns {
    order(id: "gid://shopify/Order/556763556582") {
        id
        returns(first: 5) {
            edges {
                node {
                    id
                    status
                    returnLineItems(first: 50) {
                        edges {
                            node {
                                id
                            }
                        }
                    }
                    refunds(first: 5) {
                        edges {
                            node {
                                id
                            }
                        }
                    }
                }
            }
            nodes {
                id
                status
                returnLineItems(first: 5) {
                    edges {
                        node {
                            id
                            quantity
                            refundableQuantity
                            refundedQuantity
                            returnReason
                        }
                    }
                }
                refunds(first: 5) {
                    edges {
                        node {
                            id
                            createdAt
                            totalRefundedSet {
                                shopMoney {
                                    amount
                                }
                            }
                        }
                    }
                    nodes {
                        createdAt
                        id
                        refundLineItems(first: 5) {
                            edges {
                                node {
                                    id
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

Result: Still returned { edges: [], nodes: [] }. Everything else came back correctly.

Conclusion: No returns are being retrieved, even though we asked for all possible fields.

What We Know for Sure

  • Returns exist in Shopify (confirmed via DataExport.io).
  • Returns are part of the GraphQL schema (__type(name: "Order")).
  • We have the correct permissions (read_returns).
  • Returns are never returned (always edges: []).
  • Refunds work fine, but returns do not.
  • Querying returns separately also returns an empty array.
  • REST API does not expose returns.

Conclusion

Every API call we tried was successful, and all data except for returns came back as expected. We're using both Supermetrics and dataexport.io to pull data for this store, so we know for a fact that it's possible to get this data using the API.

发布评论

评论列表(0)

  1. 暂无评论