How can I retrieve orders containing a specific product using GraphQL?

Hi everyone,
I’m working with the Shopify Admin GraphQL API and I need to retrieve orders of specific products. I checked the orders query, but it doesn’t seem to support direct filtering by product ID.

Is there a way to efficiently get only the orders that contain a certain product, either by productId, variantId, or productTitle?

Bonus if there’s a way to avoid fetching all orders and filtering them manually.

Any tips or examples would be appreciated!

Thanks in advance :raising_hands:

Edit: I found product_id filter in the orders graphql but it is not in the documentation btw. I think there is no way to retrieve multi products’ orders

It seems like productTitle works with the default query like so query: "your product title"

Just keep in mind that this will search many order fields, and may result in false positives, if your productTitle is something that can be a valid value for a different field.

Alternatively you can use the sku filter to match only the sku field.