Feature request: Add lineItemsCount to Order and DraftOrder object

Use case: to display how many distinct line items an order / draft order has, to merchants.

Currently theres subtotalLineItemsQuantity property, which shows the sum of quantities across all line items, this works if all line items has 1 quantity. But if one of the line items has multiple quantities, then using this would yield incorrect result for the number of distinct line items.

There’s lineItemCount used internally by Shopify on the Admin, which is not accessible on the public Admin GraphQL, I hope this property can be accessed in the future API versions, thank you.

I am aware that I can loop through the whole lineItems connection to get the total line items count, but if my app is querying multiple orders and their line items at the same time, my app will exceed the query cost limit.

Hey @soulchild, hope all’s well, always appreciate your feature requests! :slight_smile:

Just confirming on my end, you’re right that subtotalLineItemsQuantity represents the sum of line item quantities, rather than the number of distinct line item rows. I also checked the public Admin GraphQL schema, and I’m not seeing a lineItemsCount field on either Order or DraftOrder, or a totalCount field on their lineItems connections, so you’re right on that point too.

For smaller result sets, the main workaround would be querying the lineItems connection with a minimal selection like just the line item IDs, then counting those client-side. I definitely get that’s not super ideal for querying multiple orders/draft orders at once though like you said, since expanding nested line item connections can add up quickly in query cost.

A couple of quick questions just so I can get this set up as a feature request on my side

  • Is your main use case showing this count in an order/draft order list view, or is it more for reporting/export/sync logic?
  • Roughly how many orders or draft orders would you need to show this for in a single request/page?
  • Would a connection-level totalCount on lineItems solve the use case, or would you specifically need a top-level field like lineItemsCount on Order and DraftOrder?

Happy to pass this along with that added context. Let me know if I can clarify anything on our end here - hope to hear from you soon!

Hi Alan,

Thank you for the quick response!

Is your main use case showing this count in an order/draft order list view, or is it more for reporting/export/sync logic?

My main use case is showing the count in an order / draft order list view.

Roughly how many orders or draft orders would you need to show this for in a single request/page?

About 20-50 orders / draft orders in a single request / page.

Would a connection-level totalCount on lineItems solve the use case, or would you specifically need a top-level field like lineItemsCount on Order and DraftOrder?

A connection-level totalCount on lineItems would solve the use case, either solutions work, as long as no iteration on all edges / nodes are required.

Hey @soulchild - thanks for confirming, that’s super helpful.

That gives me enough context to pass this along on our end.

I’ll loop back here if I have more info to share. Let me know if I can clarify anything else on our end.

Hey @soulchild - just following up here. I can’t confirm if this is in our roadmap currently, but just wanted to loop back with you to let you know I’ve logged this as a feature request on our end - hope this helps a little bit.