Hi All,
when I run the following query in the GraphQL app in my store it works great -
{
orders(first: 10, query: "tag:'Ship'") {
nodes {
id
tags
}
}
}
However, when I run it from my backend nodejs service it doesn’t work and returns zero results -
export const getShipOrders = async (accessToken) => {
const shopGraphQl =
"https://#########.myshopify.com/admin/api/2023-01/graphql.json";
const url = shopGraphQl;
const ORDERS_QUERY = `
query {
orders(first:10, query: "tag:'Ship'") {
edges {
node {
id
tags
}
}
}
}
`;
const body = {
query: ORDERS_QUERY,
};
const res = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Shopify-Access-Token": accessToken,
},
body: JSON.stringify(body),
});
console.log(`status = ${res.status}, ${res.statusText}`);
console.log(
"data returned:\n",
JSON.stringify((await res.json()).data.orders.edges, null, 2)
);
};
If i remove query: "tag:'Ship'" it works fine.
Similarly, if i change the query to query:"sales_channel:'Online Store'" it just seems to ignore the query and returns POS orders (i.e. ignores the query), but again if run in the GraphQL app in the store it work works fine.
The docs say they support both of these queries so not sure what i’m doing wrong!