Dev
Mock GraphQL Error Generator
GraphQL errors have a specific, non-negotiable structure: a top-level errors array where each entry carries a message, a locations array with line and column, a path array naming the failing field, and an extensions object with a machine-readable code. Getting any of these wrong means your test does not resemble what a real server sends. This generator produces spec-compliant GraphQL error payloads — the complete JSON object with data: null and a correctly-shaped errors array — ready to paste into an MSW handler or Apollo MockedProvider. The error category dropdown filters which error type is drawn: Validation generates BAD_USER_INPUT errors like field-level format failures; Authentication produces UNAUTHENTICATED and FORBIDDEN codes; NotFound returns NOT_FOUND with a realistic resource path; RateLimit gives you RATE_LIMITED errors with retry messaging. Any draws from all categories. The count input controls how many error objects appear in the errors array, from 1 to 8, for testing how your UI handles multiple simultaneous errors from a single response. The most direct use is copying the output into an MSW graphql handler's return value or into Apollo's MockedProvider as a mocked result. That lets you drive every error branch — expired token, missing field, rate cap — without touching a server.
How to use
- Choose your options above
- Click Generate
- Copy your result
Detailed instructions
- Set the number of errors.
- Choose the error category.
- Click Generate to produce a result.
- Copy the Generated GraphQL Error and use it where you need it.
Use Cases
- •Testing Apollo Client error-handling logic in Jest with realistic UNAUTHENTICATED payloads
- •Populating Storybook stories for error state UI components across all four error categories
- •Simulating concurrent validation errors in Cypress end-to-end tests for form-heavy GraphQL mutations
- •Documenting expected error shapes in Postman collections or Notion API references for frontend teams
- •Reproducing RateLimit error responses locally when a third-party GraphQL API cap is hard to trigger
Tips
- →Generate it a few times and keep the version that fits best.
- →Adjust the options above to steer the result toward what you need.
- →Replace the placeholder values with your real data before using it.
- →Everything runs free in your browser — no signup or install required.
FAQ
what does a graphql error response payload actually look like
A GraphQL error response returns HTTP 200 with a JSON body containing a null or partial data field and an errors array. Each error object includes message, locations, path, and an extensions field that typically carries a machine-readable code like BAD_USER_INPUT or UNAUTHENTICATED.
why does graphql return 200 ok even when there's an error
GraphQL treats HTTP as a transport layer, not a semantic one — so it always returns 200 and encodes error details in the response body's errors array. This means your client code must check for errors in the JSON rather than relying on HTTP status codes, which is why mocking these payloads during testing is so important.
can I use these mock payloads with MSW or Apollo mocks in a React app
Yes. Copy the generated payload and return it from an MSW rest or graphql handler, or pass it directly to Apollo Client's MockedProvider as the result. This lets you test every error branch — validation, auth, rate limiting — without touching a real server.
what is the difference between UNAUTHENTICATED and FORBIDDEN error codes
UNAUTHENTICATED means the request lacks valid credentials — the server does not know who is calling. FORBIDDEN means the caller is authenticated but does not have permission to access the requested field or resource. Your client UI should handle these differently: UNAUTHENTICATED typically triggers a redirect to login, while FORBIDDEN should show an access-denied message.
You might also like
Popular tools from other categories that share themes with this one.
Try these next
More free tools from other corners of the catalog, picked by shared themes.