Filter list of Products by Collection ID and an array of Tags - GraphQL API

davebeauchemin
Shopify Partner
5 0 1

Hi there,

 

Anyone knows how we could filter a list of Products from a specific Collection ID and an array of [tags] with the GraphQL Storefront API ?

 

I looked into the documentation and the only way to filter products would be with the Products query but it accept only a set of Product IDs and a set of Tags, there is no way to add a Collection ID arguments to the query params.

 

The other way is with the Collection query which can return a list of available products but again here we can't filter products based on a set of Tags.

 

Thanks!

Replies 2 (2)

rpbiwer
Shopify Partner
19 0 6

Hey @davebeauchemin , did you ever find a solution? I'm running into the same thing now.

davebeauchemin
Shopify Partner
5 0 1

Hey @rpbiwer I find a way to achieve this (but not the best in my opinion) by syncing products with my custom application. I'm using KeystoneJS for the backend so I created a Product type, Collection type and Tag type. Then I configured the Product Type to contain the Product ID from Shopify and a relationship with Collection and Tag from Keystone. Then I am filtering out my own database and once I get all available products for the specific Collection and Tag I'm making a query to Shopify to get all details related to the available products.