Graphql - getting sku's sold in last 12 months

What’s the best way to get a list of sku’s with the number of sales for each from the last year.

At the moment I’m getting the list of order id’s, and then for each order, getting it’s details and reading through the lineitems. But it’s taking a while to run as there’s a query per order.

Is there a better way ?

I was about to link the shopifyqlQuery API, but apparently it is sunset.

Was pretty neat to be able to just extract this data by pasting the ShopifyQL query into the API:

Then I think you’ll have to use the Order API. Not sure the precise correct usage in your case, but consider the BulkOperation, if you did not already.