Return filters from a storefront query

We’re trying to try to return a set of filters on a product from a query using the Storefront API.

https://shopify.dev/api/storefront/2022-07/queries/products

https://shopify.dev/api/storefront/2022-07/objects/Filter

When we send the following query:

query prods {

  products(first: 250, query: "title:Test* OR product_type:shoes") {  

     filters {

        id

        label

        values {

          id

          label

          count

        }

      }

      edges {

        node {

            id

            title  

            productType

            vendor

        }  

      }

  }

}

We get the following error:

“message”: “Field ‘filters’ doesn’t exist on type ‘ProductConnection’”

What should be returned for the ‘filters’ field, and why do we get an error here?

When we send the same type of query for a collection, we get more of an anticipated result:

query Facets {

  collectionByHandle(handle: "test-collection") {

    handle

    products(first: 10) {

      filters {

        id

        label

        type

        values {

          id

          label

          count

          input

        }

      }

    }

  }

}

Results in receiving the filters as expected.

As a workaround, we could make a collection with all the products in it and perform the query that way, but that’s not ideal.

Is there any additional documentation as to how this works, or how we can get the product query to behave as expected?

Thank You,

I also have the same issue. Have you found any solution?

The answer that Shopify gave me was that storefront filters only work in the context of a collection or search results object.

It would only work on collection.products not for products