All things Shopify and commerce
My goal is to send a Storefront API request that allows be to grab X first products based on collection handle that are filtered by min/max price and title search. However, this doesn't seem to be possible right now.
Currently, I am able to achieve this partially requiring client-side filtering outside of the request.
Method: Use the collection query with the handle filter, but the ProductsConnection it returns does not allow for the query parameter to be used in the subsequent products query.
{
"query": "query getProducts($handle: String!, $first: Int, $sortKey: ProductCollectionSortKeys, $reverse: Boolean, $query: String) { collection(handle: $handle) { products(first: $first, sortKey: $sortKey, reverse: $reverse, query: $query) { edges { node { id title description handle availableForSale onlineStoreUrl variants(first: 10) { edges { node { id title sku availableForSale priceV2 { amount currencyCode } compareAtPriceV2 { amount currencyCode } } } } featuredImage { altText url height width } } } } } }",
"variables": {
"handle": "shirts",
"first": 1,
"query": "title: *t*"
}
}
This query returns the error:
{
"errors": [
{
"message": "Field 'products' doesn't accept argument 'query'",
"locations": [
{
"line": 1,
"column": 216
}
],
"path": [
"query getProducts",
"collection",
"products",
"query"
],
"extensions": {
"code": "argumentNotAccepted",
"name": "products",
"typeName": "Field",
"argumentName": "query"
}
},
{
"message": "Variable $query is declared by getProducts but not used",
"locations": [
{
"line": 1,
"column": 1
}
],
"path": [
"query getProducts"
],
"extensions": {
"code": "variableNotUsed",
"variableName": "query"
}
}
]
}
This makes sense because in the docs the ProductConnection doesn't allow for query, but I don't understand why. Is there any way this can be added so I don't have to make multiple requests and then have to filter client-side?
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025