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.
We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024The Hydrogen Visual Editor is now available to merchants in Shopify Editions | Summer '...
By JasonH Sep 2, 2024