Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I'm experiencing some unexpected handling and an error attempting to search products.
Context
Using the following approach, the response I get doesn't seem to respect whether the `first` argument is present or not, unless it's malformed. The focus here is on the `products()` query, but I've included some extra methodology in case there's something more to this.
await fetch(endpoint, {
method: "POST",
headers: {
X-Shopify-Storefront-Access-Token: ***,
"Content-Type": "application/json"
}
body: JSON.stringify({
query: `query {
products(first: 10, query: "arbitrary") {
edges { ... }
}
}`
})
})
This runs and returned an error with the message: 'you must provide one of first or last' despite that `first` is clearly there.
Strangely, when I intentionally convert the value for `first` into a string, rather than the required `Int`, the server rightly detects the `first` argument, and barks about the incorrect type.
`products(first: "10", query: "some-value")` -> `message: Argument 'first' on Field 'products' has an invalid value ("10"). Expected type 'Int'.`
Anybody run into this before or have any ideas? It seems very odd to me, if not unstable. Additionally, I've (only once) been able to recreate this behavior at the Graphiql shopify.dev provides, but a refresh of the page cleared it up. No such luck on my project, however.
I've figured it out and will close the loop here.
Further down in my query body I was asking for the `images` node and unaware that also required a `first` argument. I could see the error message in terminal, but the locations array was collapsed and I didn't stop to expand that.
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025