Graphql total count products?

Anonymous
Not applicable

Hi

Is there a field to get the total count of the products in my store?

Replies 4 (4)
Vellir
Shopify Partner
134 29 37

I was recently looking for the same thing in the GraphQL API and couldn't find so I had to use the REST one:

curl --location --request GET '{YOUR_STORE_URL}/admin/api/{API_VERSION}/products/count.json' \
--header 'Content-Type: application/json' \
--header 'X-Shopify-Access-Token: YOUR_TOKEN'

 

https://shopify.dev/docs/admin-api/rest/reference/products/product#count-2021-01 

- Yes, we build Shopify Apps. Hit me with your idea: https://vellir.tech
- Let customers preview your products and easily add them to cart with Peek Mode
- Add free, good looking social share icons with built-in analytics to your store with Share Lab
- Manage your new arrivals with Newr
hmanlig
Tourist
5 0 1

This is using the REST api, not GraphQL?

helmutgranda
New Member
3 0 0
query MyQuery {
  allShopifyProduct {
    totalCount
  }
}
BenMurphySmith
Tourist
3 2 14

This query does not work. Shopify's implementation of GraphQL does not include ability to query "totalCount" from anything.

The confusion on this point seems to be that experienced GraphQL developers know that "totalCount" is a routine part of the Cursor Connection spec recommended by The GraphQL Foundation: https://graphql.org/learn/pagination/

I think many many developers would be well served by the complete implementation of "totalCount" into the Shopify GraphQL API. Having an idea of the amount of data we're about to page through would be supremely helpful to app developers in tackling a number of development issues. Who do we pester at Shopify to get this implemented?