GraphQL query filtering not working (works in GraphQL App)

Topic summary

A developer is experiencing inconsistent behavior with GraphQL query filtering in Shopify’s Admin API. The query orders(first: 10, query: "tag:'Ship'") works correctly when executed in the GraphQL app within the Shopify store, returning the expected filtered results.

However, the same query fails when run from a Node.js backend service using fetch, returning zero results. The query appears to be ignored entirely—removing the filter returns all orders successfully, and adding different filters (like query: "sales_channel:'Online Store'") also gets ignored, returning unfiltered POS orders instead.

Key observations:

  • Query works: GraphQL app (in-store)
  • Query fails: Node.js fetch implementation
  • Without filters, the API call works fine
  • The Shopify docs indicate both query formats should be supported

One commenter suggested using Shopify’s official Node.js SDK GraphQL client to simplify development. The original poster plans to use the Shopify App JS GraphQL client library eventually, but is currently using basic fetch to isolate whether the issue lies with the API itself rather than client library code.

Status: Unresolved; seeking help to identify why the query filter works in one context but not the other.

Summarized with AI on November 21. AI used: claude-sonnet-4-5-20250929.

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

1 Like

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.