Trying to query all refunds

Solved
stefaniaoverman
New Member
2 0 0

Hello,
I need to be able to consume all the returns (regardless of the orderId) of shopify with their respective line items, when searching in the documentation I saw that at least with the Rest API  this is not possible, because to obtain it I must provide the id of an order.

I was wondering if it is possible to do this (get all returns regardless of orderId) via GraphQL

0 Likes
Greg_Kujawa
Shopify Partner
965 80 204

This is an accepted solution.

Here is an example using the Shopify GraphQL. Worked when I ran a quick test a minute ago.

 

{
  orders(first: 10, query: "financial_status:refunded") {
    edges {
      node {
        id
        name
        refunds(first: 10) {
          id
          createdAt
          legacyResourceId
          refundLineItems(first: 5) {
            edges {
              node {
                lineItem {
                  id
                  name
                  quantity
                  originalUnitPriceSet { 
                    presentmentMoney { 
                      amount 
                      currencyCode 
                    } 
                  }
                  discountedUnitPriceSet {
                    presentmentMoney { 
                      amount 
                      currencyCode 
                    }
                  }
                }
                location {
                  id
                  name
                }
              }
            }
          }
          totalRefundedSet {
            presentmentMoney {
              amount
              currencyCode
            }
          }
        }
      }
    }
  }
}

 

Or as a bulk operation: 

mutation {
  bulkOperationRunQuery(
   query: """
   {
    	orders(query: "financial_status:refunded") {
    edges {
      node {
        id
        totalPriceSet {
          shopMoney {
            amount
          }}
        name
        displayFinancialStatus
        displayFulfillmentStatus
        
        lineItems {
          edges {
            node {
              id
              variant {
                id
              }
              quantity
              fulfillmentStatus
              fulfillableQuantity
              refundableQuantity
            }}}
        transactions {
          id
          kind
          amountSet {
            shopMoney {
              amount
    }}}}}
  }
  }
    """
  ) {
    bulkOperation {
      id
      status
    }
    userErrors {
      field
      message
    }
  }
}

 

0 Likes
stefaniaoverman
New Member
2 0 0

Thank you so much @Greg_Kujawa !!

0 Likes