GraphQL query filtering not working (works in GraphQL App)

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!

Maybe not a complete reply, but Shopify nodejs SDK has a GraphQL client which could simplify development. https://github.com/Shopify/shopify-api-js/blob/main/lib/clients/graphql/graphql_client.ts

Thanks, yeah I will be using the GraphQL client library used with Shopify App Js once I solve this problem. But they exhibit the same issue as what i’m having and i wanted to isolate the problem to the actual API rather than the possibility of it being the client code that is the issue. Hence the rather basic fetch implementation.