No way to filter products query by collection

In REST API it was possible to filter products list by collection like this:

ShopifyAPI::Product.all(collection_id: "...")

We have similar filter on productVariants query in Graphql:

But for some reason this filter is not available for products and productsCount queries:

It is possible to get products using collection query, but it doesn’t supports product filtering by status, so it’s not a viable replacement for an old REST approach.

This is critical issue for us, as it doesn’t allows us to fully migrate to the new products API and the deadline is approaching quickly.

4 Likes

Connecting with the product team on this one Kirill - will update when I know more.

1 Like

What’s stopping you from querying the products of a collection and including the filter query within that? Is that what you are saying does not work?

I believe it would look something like the following, if it works (as I have not had a chance to test this sort of solution).

collection(id: "X") {
  products(query: "Y") {
    ...
  }
}

There’s no query argument on products connection inside collection resource. And I had issue with collection resource returning empty product list randomly so can’t really trust it.

1 Like

Hi Kirill,

After connecting with the Products API team on this, we’ve recorded this limitation and will work on a fix. I don’t have an ETA to share right now, but will update here once available.

4 Likes

@Liam-Shopify Any chance it will be fixed before the deadline for Graphql products API migration (2025-02-01)? Not much time left and I don’t see any workaround to complete migration.

@Liam-Shopify any update on this? API v2025-01 still doesn’t have the filter and we don’t have time left to wait for the fix. I guess now the only option is to use products from collection resource and filter products on the backend?

Hi Kirill,

The only update I can give on this is that our devs are currently working on releasing the required filter, but there’s no ETA to share on this as of today. I’m following the progress of this and will update here once it’s available.

3 Likes

Just to understand, we are talking about passing in the collection id as a possible query parameter in the products query, or being able to pass the query parameter in the products connection of the collection query?

This appears to have been released yesterday:

2 Likes

I’m seeing very strange behavior when using these filters: Filtering products by collection_id not working properly