Storefront GraphQL API Filter Groups

Hello,

We are facing an issue with the Storefront GraphQL API filters and the Shopify Search & Discovery App. We built a custom theme filtering solution a while back for a merchant that uses a set of Storefront API access enabled metafield definitions. Those definitions have individual filter values grouped through the Shopify Search & Discover App so that we can create range filters for metafield values.

This approach has worked up until recently, and it appears it’s now only returning results matching exact values instead of by the groups’ value.

We use the following GQL query to fetch/filter products for a collection:

query getProducts($first: Int, $after: String, $handle: String, $filters: [ProductFilter!], $sortKey: ProductCollectionSortKeys, $reverse: Boolean) {
    collection(handle: $handle) {
        products(first: $first, after: $after, filters: $filters, sortKey: $sortKey, reverse: $reverse) {
            edges {
                cursor
                node {
                    title
                    productType
                    availableForSale
                    onlineStoreUrl
                    handle
                    variants(first: 1) { 
                        edges {
                            node {
                                priceV2 {
                                    amount
                                }
                                compareAtPriceV2 {
                                    amount
                                }
                            }
                        }
                    }
                    images(first: 4) {
                        edges {
                            node {
                                originalSrc
                                altText
                            }
                        }
                    }
                    metafield(namespace: "global", key: "[key]") {
                        namespace
                        key
                        value
                    }
                }
            }
            pageInfo {
                hasNextPage
            }
        }
    }
}

Here’s an example query input:

{
    "first": 250,
    "after": null,
    "filters": [
        {
            "productMetafield": {
                "namespace": "global",
                "key": "[key_0]",
                "value": "[value]"
            },
            "productMetafield": {
                "namespace": "global",
                "key": "[key_0]",
                "value": "[value]"
            },
            "productMetafield": {
                "namespace": "global",
                "key": "[key_1]",
                "value": "[value]"
            },
        }
    ],
    "handle": "all",
    "sortKey": "MANUAL",
    "reverse": false
}

We haven’t been able to find any related breaking changes in the Shopify Developer Changelog to indicate a change in API behavior, but we found a few similar posts here in the forums from earlier this month.

Storefront GraphQL API returns no filters - New GraphQL Product APIs - Shopify Developer Community Forums

Storefront API - Collection Filters Are Not Responding - Hydrogen and Storefront APIs - Shopify Developer Community Forums

Let us know if you need any additional information. This issue is affecting a merchant’s live store and we would like to get it resolved as soon as possible.

Thanks!

Does it perhaps relate to this (16th March)?

Thanks for the link. That doesn’t seem directly related because we aren’t using Storefront filter URL’s but that change log might imply some larger underlying changes about how the Shopify GraphQL API now handles grouped values.

@SaltechSystems, I saw this post on LinkedIn today. Maybe this is related?

This is the same thing as I posted above.

1 Like

@remy727 Thank you for your time.

Does anyone know if the Shopify Storefront GQL API supports querying for items inside of a given FilterSettingGroup?

For example, if we know the group they selected, can the API return items from within that group?

Bumping!

Re: Did Shopify Storefront GQL alter how grouped values work in conjunction with fetching?