FROM CACHE - en_header

How to retrieve all payout associated orders?

stretch0
Tourist
5 0 1

Via the Admin GraphQL API, I am trying to retrieve all the payouts and their associated orders.

I seem to be able to retrieve payouts like so:

{
  payouts(first: 250) {
    edges {
      node {
        id
        net {
          amount
          currencyCode
        }
        issuedAt
      }
    }
  }
} 

But then how can I retreive orders for each payout?

Doesn't look like payout has an orders field so am I supposed to do a new query for orders each payout id?

i.e.

{
  orders(first: 250 query: "id='1'") {
    edges {
      node {
        id
        amount
      }
    }
  }
}

 

Perhaps there is another query I am missing which includes all this data because I would really like to try avoid making so many API calls if possible

Replies 3 (3)
awwdam
Shopify Staff
Shopify Staff
246 41 30

Hey @stretch0,

I took a closer look at both object's documentation: Order doesn't have a field or connection to return payout data, and similarly ShopifyPaymentsPayout mirrors this for order data. After much digging and testing, since there is no connection on either to the other, multiple queries would be needed if data from both objects is required. - Cheers. 

awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

stretch0
Tourist
5 0 1

Hi @awwdam.

Thanks for getting back to me. I thought that might be the case. Do you know if there is any plans to have a connection between the two models? Would be helpful to know what the order details are for each payout.

Also were you actually able to retrieve orders via the graphql endpoint? According to this issue, there is a bug with scopes preventing orders being returned. I ran into this issue which appears to have been lurking for almost 2 years.

stretch0
Tourist
5 0 1

Hey @awwdam. Any update on this?