Hi
Really odd error
Querying orders using the GraphQL api, sorted out all the syntax errors and the fields in wrong location etc etc.
Now just getting a “Code: 400, Bad request” with no other information.
Here is part of the erroring code
query($cursor: String) {
orders(first: 250, after: $cursor, query: "delivery_method:local") {
edges {
if I remove the query: the part becomes
query($cursor: String) {
orders(first: 250, after: $cursor) {
edges {
and it works.
So there is something about the query: it does not like, I’ve done quite a bit of investigation and it seems correct.
Anyone got any ideas?
Jules
Good practice is to specify sort order for consistency and check the hasNextPage before continuing – maybe there is no next page?
Just tested this in GraphiQL App:
orders(first: 4, query: "delivery_method:shipping", after: "XXX==" ){ ... }
delivery_method:local should be valid - the field is supported and “local” maps to the LOCAL enum. tim_1’s test with “shipping” working confirms the field name itself is fine, so the 400 is something else.
400 with no detail is the kicker - the response body almost always has an errors[] array with the real cause. Most clients only surface the HTTP status. Try logging the full response text:
const text = await res.text();
console.log(text);
Two angles to check:
- API version -
delivery_method in the orders search query was added in a specific release. Older versions return 400 if the field isn’t recognized. What’s your X-Shopify-API-Version header?
- Cursor + query mismatch - I’ve hit 400 when the
after cursor was generated under a different query string. Try first without after, just orders(first: 250, query: "delivery_method:local") - if that works, the cursor is the issue.
Also worth running the exact query in the Shopify GraphiQL App against the same store - strips out anything in your client layer.
What API version are you on?
Think it must be the API version, it’s 2025-10, not returning any errors at all
My test works in 2025-07 – the oldest GraphiQL offers.
Figured it out, needed to escape the " so changed to “delivery_method:local” to \“delivery_method:local\”