Issue using GraphQL products query savedSearchId and "where collection is" filter

I have found an issue when using a products query with the savedSearchId parameter where the results are not what I am expecting. [docs]

Reproduction Steps1. Create a custom collection, Collection A

  1. Create some products (Product 1, Product 2, Product 3)
  2. Put Product 1 into Collection A
  3. Create a Saved Search using filter “where collection is Collection A”
  4. Perform the following GraphQL query
{
    products(first: 25, savedSearchId: "gid://shopify/SavedSearch/1234567890") {
        edges {
            node {
                title
            }
        }
    }
}

Expected Results

I expect to only see Product 1 in the result.

Actual Results

I see all products.

Thoughts

The issue appears to be specifically related to the “collection is” filter. I should also note, that the Saved Search result is correct in the Shopify interface. The issue is only with the GraphQL query performed through the API.

Can someone from Shopify confirm this issue?

The issue is that the saved search’s query is used as the query argument for the products query. And the products query doesn’t filter by collection_id. This results in an empty query and that returns all of the products.

See also: