Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Exclude empty collections from query

Exclude empty collections from query

abater
Shopify Partner
8 0 2

Is it possible to exclude empty collections from my query when using the Storefront API? I'm trying to construct a menu and I don't want to present collections with no products.

Reply 1 (1)

c10s
Shopify Partner
67 12 27

I don't believe there is a way to do it with the API alone. Would filtering the query result on the client before constructing the menu work? (eg. if products.edges is an empty array you know it's an empty collection)