How do I search for line items?

BeamJokerFavor
Excursionist
36 2 2

I want to find all lineItem product ids from my orders. What would this query look like in GraphQL?

0 Likes
_JCC_
Shopify Staff
Shopify Staff
145 20 26

Hey @BeamJokerFavor ,

Happy to help you with this. The lineItems connection (part of the order query) will give you access to the product id both from the line item node, and variant connection. For simplicity this example shows the use of the lineItems connection on an order query

query{
  order(id:"gid://shopify/Order/someorderid"){
    lineItems(first:10){
      edges{
        node{
          id
          quantity
          name          
          product{
            id
          }
          variant{
            id,
            product{
              id
            }
          }
        }
      }
    }
  }
  
}

If you have any other questions please don't hesitate to reach out.

Regards,

John

John C | Developer 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

0 Likes
BeamJokerFavor
Excursionist
36 2 2

I was actually looking to find all the line items in all my orders. That would be nested. I had trouble with quota limits. Just change it to ```orders(first:20)``` or something like that, and page through?

0 Likes
_JCC_
Shopify Staff
Shopify Staff
145 20 26

Hey @BeamJokerFavor ,

Sorry I missed that, yes you can change my example to an orders query, and use cursor based paging to go through a list of orders. Another option is to use our bulk query operation api.

Regards,

John

John C | Developer 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

0 Likes