Get Orders With Specific Products via GraphiQL

Get Orders With Specific Products via GraphiQL

DevBijan
Shopify Partner
54 2 17

Hi all, I wanted to see if it's possible to get orders from my store containing a specific product? 

 

The goal is to get the custom attributes from these products, however not every order has products with custom attributes. So I basically want to filter through the orders by product ID/Handle and only return the orders containing that product.

 

My GQL:

 

{
  orders(first: 5, reverse: true) {
    edges {
      node {
        name
        customer {
          firstName
          lastName
        }
        lineItems(first: 50) {
          edges {
            node {
              product{
                id
              	title
              }
               customAttributes {
                key
                value
              }
            }
          }
        }
      }
    }
  }
}
Replies 0 (0)