Shopify GraphQL userErrors: Why a 200 Still Failed

Shopify GraphQL userErrors are the third of three places a mutation can fail, after the HTTP status and a top-level errors array. They arrive with 200 OK, inside the mutation’s own payload. None of the three Shopify Node packages we tested throws on them or flags them, so the check is yours to write.

We ran @shopify/admin-api-client 2.0.1, @shopify/shopify-api 15.1.3 and the admin.graphql() helper from @shopify/shopify-app-react-router 4.0.5 (reached through unauthenticated.admin) against a local server on 3 December 2026. The server replayed the error bodies printed in Shopify’s documentation. Where the docs print none, we wrote a stand-in: the response with data and errors together, and the 401, 429, 502 and 503 bodies. No store was involved, so the client behaviour below is observed and the response shapes are not.

Where does a Shopify mutation report failure?

The GraphQL Admin API reference, at version 2026-10 when we read it, says the API “can return a 200 OK response code in cases that would typically produce 4xx or 5xx errors in REST”. Shopify’s page on response status and error codes is blunter: a 200 “means Shopify answered, not that the operation worked”.

Top-level errors mean the request as a whole hit trouble. Each entry carries a code at errors[n].extensions.code, and the reference lists four: THROTTLED, ACCESS_DENIED, SHOP_INACTIVE and INTERNAL_SERVER_ERROR. It adds that other codes may appear, and its own sample shows a fifth, MAX_COST_EXCEEDED.

A real HTTP error status is rare. The reference says 4xx and 5xx responses “occur infrequently”, and lists a frozen shop (402), a shop marked as fraudulent (403) and a locked shop (423) among them.

Then there is the third layer. This is Shopify’s own example response for a collectionDelete given an ID that does not exist:

{
  "data": {
    "collectionDelete": {
      "deletedCollectionId": null,
      "userErrors": [
        {
          "field": ["id"],
          "message": "Collection does not exist"
        }
      ]
    }
  }
}

The status is 200, there is no errors key, and deletedCollectionId is null. Each user error has a message and a field, and the reference defines field as “the path to the input field that caused the error, or null”. The same section states the rule everything below depends on:

The response confirms that a mutation succeeded only when it has no top-level errors and the mutation payload error field is empty.

What do Shopify’s Node clients do with each failure?

@shopify/admin-api-client never threw in any case we ran, a refused connection included: request() always resolved, and a failure showed up as an errors object beside data or in place of it. @shopify/shopify-api and admin.graphql() threw for everything except user errors. The table shows each with its default options.

Response servedadmin-api-client request()shopify-api request() and admin.graphql()
200, userErrors filledresolves with data onlyresolves with data only
200, top-level errorsresolves with errors.graphQLErrors, no datathrows GraphqlQueryError
200, data and errors togetherresolves with boththrows GraphqlQueryError, data on error.body.data
401, 403, 404, 423resolves with errors.networkStatusCodethrows HttpResponseError
500, 502, 503resolves with errors.networkStatusCodethrows HttpInternalError
Connection refusedresolves with errors.message onlythrows HttpRequestError

A try/catch around the low-level client’s request() therefore caught nothing in our runs. On a 401, const { data } = await client.request(...) left data as undefined and raised no exception.

With admin.graphql(), checking response.ok tells you nothing. The helper builds a new Response from the parsed result, so the status was 200 whenever it returned at all. Failures threw before a Response existed.

The first row is the same in both columns. The README for @shopify/admin-api-client says so outright: its errors object “does not include any UserErrors”.

Shopify’s React Router app template shows how the gap gets inherited. As it stood on 3 December 2026, the sample action in app/routes/app._index.tsx runs productCreate and productVariantsBulkUpdate without selecting userErrors, then reads the product through non-null assertions. It is demo code, but an action copied from it has no check to inherit.

Does the retries option cover THROTTLED?

Not in our runs. With retries: 2, @shopify/admin-api-client sent a 429 three times and a 503 three times. A 500, a 502 and a 200 carrying THROTTLED were each sent once.

Shopify’s response-codes page says the GraphQL Admin API does not use 429 for rate limiting and reports a THROTTLED error in a 200 instead. Going by the docs, then, the rate limit never reaches the branch that retries. Waiting and resending is left to your code, and our post on budgeting Admin API calls by query cost has a client that does it.

How do we stop Shopify GraphQL userErrors going unnoticed?

Put the check in one place and make it throw. This module turns all three layers into exceptions for @shopify/admin-api-client, and exports the user-error check on its own for code that already goes through admin.graphql().

import type { AdminApiClient } from "@shopify/admin-api-client";

type UserError = { field?: string[] | null; message: string; code?: string | null };

export class ShopifyRequestError extends Error {
  status?: number;
  codes: string[];
  constructor(message: string, status: number | undefined, codes: string[]) {
    super(message);
    this.name = "ShopifyRequestError";
    this.status = status;
    this.codes = codes;
  }
}

export class ShopifyUserErrors extends Error {
  userErrors: UserError[];
  constructor(mutation: string, userErrors: UserError[]) {
    super(`${mutation}: ${userErrors.map((e) => e.message).join("; ")}`);
    this.name = "ShopifyUserErrors";
    this.userErrors = userErrors;
  }
}

export function assertNoUserErrors(data: unknown): void {
  for (const [mutation, payload] of Object.entries(data ?? {})) {
    for (const [key, value] of Object.entries(payload ?? {})) {
      if (/userErrors$/i.test(key) && Array.isArray(value) && value.length > 0) {
        throw new ShopifyUserErrors(mutation, value);
      }
    }
  }
}

export async function mutate<TData>(
  client: AdminApiClient,
  operation: string,
  variables?: Record<string, unknown>,
): Promise<TData> {
  const { data, errors } = await client.request<TData>(operation, { variables });

  if (errors) {
    const codes = (errors.graphQLErrors ?? []).map((e) => String(e.extensions?.code ?? "UNKNOWN"));
    throw new ShopifyRequestError(errors.message ?? "Request failed", errors.networkStatusCode, codes);
  }

  assertNoUserErrors(data);
  return data as TData;
}

The inner loop matches any field whose name ends in userErrors because, in the reference’s words, the field’s “name varies by API and mutation”. The deprecated productCreateMedia, for one, returns mediaUserErrors. The outer loop walks every top-level key, so a document that runs two mutations has both payloads checked.

It only works if the operation selects the field. GraphQL returns what you ask for, and a mutation written without userErrors { field message } gives the check nothing to find. Some payloads offer more: MetafieldsSetUserError adds a code and an elementIndex, and they are worth selecting where they exist.

With the app package, the same check is three lines:

const response = await admin.graphql(OPERATION, { variables });
const { data } = await response.json();
assertNoUserErrors(data);

Which failures are safe to retry?

A user error is about your input or the state of the shop. The UserError reference describes “validation failures, such as invalid field values or business logic violations, that prevent the operation from completing”. We would expect the same request to get the same answer, so record it against the item and move on. The exception is a conflict code such as STALE_OBJECT on metafieldsSet, which the reference describes as “The metafield has been modified since it was loaded”. That one needs a fresh read and another attempt, and our metafieldsSet walkthrough has the loop.

A top-level error does not tell you whether the write happened. The reference’s instruction is to “check whether the change happened before you retry a mutation that returned top-level errors”. It says a mutation whose query or variables fail validation does not run, but other errors, a server error among them, “can happen after the mutation has saved its changes”. An INTERNAL_SERVER_ERROR on a create mutation is therefore the one to be careful with: if the create did save, a blind retry makes a second record.

For that case Shopify documents idempotent requests. Some mutations take an idempotency key as an input field, others through an @idempotent directive, and the page says repeated requests with the same parameters “are executed only once”. Which mutations accept one is stated mutation by mutation, so read the reference before relying on it. We have not run either mechanism against a store.

What we would do

Route every Admin mutation through one function that throws on all three layers, and let nothing else call the client. Select userErrors in every mutation, plus code where the payload type has one. Keep the error classes separate so a job runner can tell “fix the data” from “wait and resend” from “find out whether it happened”.

We would not point this module at the Storefront API without reading that API’s own error-handling section first. Everything here was written and tested against the Admin API. Nor would we treat the table as permanent, since it describes three package versions on one day. A dozen assertions in your own test suite, fed with the documented error bodies, would tell you when a new major version changes the answer.

We connect Shopify stores to accounting, shipping and email systems, and we take on stores whose original developer has moved on. If your integration reports success for writes that never landed, our Shopify development team can find where the errors are being dropped.

Need this built properly?

Get in touch

Hack the planet!