A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I'm trying to retrieve all orders with a particular Tag. But it returns 0 results -
const ORDERS_QUERY = `
query {
orders(first:100, query:"tag:Ship") {
edges {
node {
id
name
tags
}
}
}
}
`;
export default function applyOrdersApiEndpoints(app) {
app.use(express.json());
app.get("/api/weekorders", async (req, res) => {
const client = new shopify.api.clients.Graphql({
session: res.locals.shopify.session,
});
const orders = await client.query({
data: {
query: ORDERS_QUERY
},
});
res.send(orders.body.data);
});
}
The Admin api docs suggest that `tag` is valid query parameter so i'm not sure what i'm missing - https://shopify.dev/docs/api/admin-graphql/2023-01/objects/order#queries
Thanks
Solved! Go to the solution
This is an accepted solution.
Hey There,
Not sure what package you are using there but I don't know the endpoint "api/weekorders" you sure thats not a typo?
I tried your query on a dev shop and it works fine from within the graphiql app
Cheers,
Gary
This is an accepted solution.
Hey There,
Not sure what package you are using there but I don't know the endpoint "api/weekorders" you sure thats not a typo?
I tried your query on a dev shop and it works fine from within the graphiql app
Cheers,
Gary
Thanks, Hmm yeah i just tried my query on the graphql app in my store and it worked! So don't know what the hell is going on with the node graphql client i'm using but it isn't behaving the same as the graphql app.
Just for some background. The query is being run from a backend express app which is an adapted version of the Shopify QRCode example app - https://shopify.dev/docs/apps/getting-started/build-app-example
The only difference between that example app and mine is that i've added another backend endpoint hosting up - "/api/weekorders". That isn't anything to do with the graphql query i'm sending to shopify.
I think this must be something to do with the version of the client or something
I think i may have found my issue (but not found a solution yet). As suggested by @garyrgilbert, the problem appears not to be with the query (which works fine and is actually a good example of filtering orders by tag). The problem appears to be something to do with the shopify client from the QR Code example app, which may be using the REST version of the admin api which has limited support for filtering. I think this is the library it's using - https://github.com/Shopify/shopify-api-js/blob/main/docs/guides/rest-resources.md
So i'm going to close this and open a new Topic based on that question.
Thanks for your help!