Get total number of products in collection with Storefront API GraphQL

Highlighted
Shopify Partner
10 0 1

I've been browesing several topics in this forum but I haven't found any answer.

We are doing a React webapp which uses the Storefront API with GraphQL. On collection page we would like to list 10 products and display a pagination index, eg: "1, 2, 3 ... last"

Unfortunately I havent found any way to get the total number of products per collection. 

It'd be great to have a totalCount like this http://graphql.org/learn/pagination/#complete-connection-model but it isn't implemented. How can I achieve the same thing?

1 Like
Highlighted
Shopify Partner
2 0 0

There is no totalCount parameter in the SDK. Just use hasNextPage

0 Likes
Highlighted
Shopify Partner
10 0 1

That's what we're doing temprarely. Having a totalCount would be great, otherwise you have to do convoluted workaround to get that information.

0 Likes
Highlighted
Shopify Partner
2 0 0

I do not know what your visual solutions are for pagination. Show please, can we find a solution

0 Likes
Highlighted
Shopify Partner
10 0 1

 

That's the one.

If there are more than 6 pages it becomes 1 2 3 ... 7 8 9. 

Without totalCount I can only use the NEXT button

0 Likes
Highlighted
Shopify Partner
10 0 1

I'm thinking of using Shopify Admin API to retrieve the total number with this https://help.shopify.com/api/reference/product#count

0 Likes