Can get products using REST but GraphQL always returns 404

Topic summary

Issue: GraphQL queries to Shopify’s API consistently return 404 errors, while REST API calls work successfully using the same credentials and access token.

Code Details:

  • REST endpoint works: https://{SHOPIFY_STORE_NAME}.myshopify.com/admin/api/2023-01/products.json
  • GraphQL endpoint fails: https://{SHOPIFY_STORE_NAME}.myshopify.com/admin/api/2023-01/graphql.json
  • Both use identical authentication headers (X-Shopify-Access-Token)
  • The GraphQL query itself is valid (tested successfully in Shopify’s GraphQL explorer)
  • Testing with SpaceX’s public GraphQL API confirmed the code structure works correctly

Resolution: The store’s domain name was recently changed. The REST API continued working with the old domain (oldName.myshopify.com), but GraphQL requires the new domain (newName.myshopify.com). Updating to the current store domain resolved the 404 errors.

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

Hi, I can’t get products using Graphql (I’m always getting a 404), but I can get them using the REST API.

I have tested the query in Shopify’s Graphql explorer. I really don’t know what else I can do.

Thanks in advance.

This is my code:

getProductsUsingRest method (works properly)

const baseUrl = `https://${config.SHOPIFY_STORE_NAME}.myshopify.com/admin/api/2023-01`

export const getProductsUsingRest = async () => {
  const headers = {
    'Content-Type': 'application/json',
    'X-Shopify-Access-Token': config.SHOPIFY_ACCESS_TOKEN,
  }
  const url = `${baseUrl}/products.json`
  const res = await axios.get(url, { headers });
  return res.data;
}

getProductsUsingGraphql method (always returns a 404)

const baseUrl = `https://${config.SHOPIFY_STORE_NAME}.myshopify.com/admin/api/2023-01`

export const getProductsUsingGraphql = async () => {
  const headers = {
    'Content-Type': 'application/graphql',
    'X-Shopify-Access-Token': config.SHOPIFY_ACCESS_TOKEN,
  }
  const url = `${baseUrl}/graphql.json`
  const query = `
  {
    products(first: 3) {
      edges {
        node {
          id,
          title
        }
      }
    }
  }`
  const res = await axios.post(url, query, {headers});
  return res.data;
}

More info about it:

I’ve tried to call SpaceX Graphql with the same structure, and it worked:

const urlSpaceX = 'https://spacex-production.up.railway.app/';
const querySpaceX = `
  {
    company {
      ceo
    }
    roadster {
      apoapsis_au
    }
  } 
`;
const res = await axios.post(urlSpaceX, {query: querySpaceX}, {headers});

So, for some reason, even though the Get Products query is ok because I’ve tested it on the Shopify Graphql explorer, is not working for me, but I know the Credential scopes are ok because I can get all products using the Rest API.

I’m even more confused than before :expressionless_face:

For anyone interested in the solution.

I’ve found that the site name was changed recently.

For some reason, the REST API works with the new store domain newName.myshopify.com but GraphQL API does not. I got it working using the old store domain oldName.myshopify.com

1 Like