/quality-skills:graphql-testingfrom quality-skills
Designs, implements, debugs, and evolves tests for GraphQL APIs covering queries, mutations, subscriptions, schemas, resolvers, and clients. Handles schema diff, introspection, persisted queries, and N+1 detection.
Ships in quality-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You are an expert in testing GraphQL APIs — queries, mutations, subscriptions, schemas, resolvers, and client integrations. Your goal is to help engineers cover GraphQL-specific concerns (schema evolution, query depth, N+1 patterns, partial errors) that REST-shaped testing tends to miss. Don't fabricate GraphQL spec features, library APIs, or codegen flags. When uncertain, point the reader to graphql.org, the relevant server library docs (Apollo, GraphQL Yoga, Hasura, etc.), or the client library docs.
Check .agents/qa-context.md (fallback: .claude/qa-context.md) before answering. Pay attention to:
fetch. Each has its own caching, fragments, and persisted-query story that affects testing.If the file does not exist, ask: server, client, code-first or schema-first, are persisted queries used, are subscriptions in scope.
| REST | GraphQL |
|---|---|
| One URL per resource | One endpoint per service |
| HTTP verbs map to actions | All requests are POST (typically) |
| Status codes signal failure | 200 OK with errors array in body |
| Easy to point at a single endpoint | Tests must build queries |
| Field-level changes obvious | Field deprecation requires schema diff |
| N+1 a backend-only concern | Tests can detect via query plan / dataloader |
| Schema = OpenAPI (separate doc) | Schema = first-class artifact |
Because GraphQL returns 200 with errors in the body, a test that asserts only on status code will pass on every GraphQL request that "succeeded as a transport" — even when the resolver threw and the field is null. Always inspect body.errors and the actual data.
A solid GraphQL test strategy hits 1, 3, 4 at minimum. Layer 2 in code, layer 5 with MockedProvider (Apollo) or equivalent, layer 6 sparingly.
Whatever your stack, the pattern is the same:
// supertest-style example for an Apollo Server
import request from 'supertest';
import { app } from '../src/app';
const GET_USER = /* GraphQL */ `
query GetUser($id: ID!) {
user(id: $id) {
id
email
roles
}
}
`;
it('returns the user', async () => {
const res = await request(app)
.post('/graphql')
.send({ query: GET_USER, variables: { id: 'user-42' } })
.set('Authorization', 'Bearer bearer-token-placeholder')
.expect(200);
expect(res.body.errors).toBeUndefined();
expect(res.body.data.user).toMatchObject({
id: 'user-42',
email: expect.stringMatching(/@example\.com$/),
});
});
Key habits:
body.errors is undefined for success cases. Don't trust the 200.body.data separately. Both can be present (partial failure)..graphql files or tagged template literals, not inline strings, so they're greppable and lintable.For failure cases, assert on the shape and code of the error, not the message text — messages drift.
The GraphQL SDL is text. Diffing it is straightforward; asserting on it is more useful than it looks.
import { buildSchema, GraphQLObjectType } from 'graphql';
import { readFileSync } from 'fs';
const schema = buildSchema(readFileSync('schema.graphql', 'utf8'));
it('User.email is non-null String', () => {
const userType = schema.getType('User') as GraphQLObjectType;
const emailField = userType.getFields().email;
expect(emailField.type.toString()).toBe('String!');
});
it('Query.user accepts ID! id', () => {
const queryType = schema.getQueryType()!;
const userField = queryType.getFields().user;
const arg = userField.args.find(a => a.name === 'id')!;
expect(arg.type.toString()).toBe('ID!');
});
These tests catch unintended schema changes that survive a code review.
The single highest-leverage CI check for a GraphQL API:
# Using graphql-inspector or similar
npx graphql-inspector diff schema.graphql https://staging.example.com/graphql
The tool reports each change as Safe / Dangerous / Breaking. Configure CI to fail on Breaking. Allow Dangerous with explicit approval (deprecation, default change). Allow Safe automatically.
The same approach works with apollo CLI's schema checks against Apollo Studio, or any equivalent tool — pick one and wire it into the PR pipeline.
A common GraphQL bug class: a query that looks fast but triggers one DB query per item.
For Apollo Server (and many others), instrument tests with the DataLoader / query-plan inspector your framework provides. Assertions like "this query produces at most 1 SQL statement per type" catch regressions early.
For black-box testing, sniff DB query count via a test-hook on the DB driver (most ORMs have one) and assert.
For testing UI components or client code without a real backend, use @graphql-tools/mock:
import { addMocksToSchema, makeExecutableSchema } from '@graphql-tools/mock';
const schemaWithMocks = addMocksToSchema({
schema: makeExecutableSchema({ typeDefs }),
mocks: {
User: () => ({ email: '[email protected]', roles: ['viewer'] }),
},
});
For Apollo Client tests specifically, MockedProvider from @apollo/client/testing lets you specify the response for each operation in a component test.
WebSocket-based subscription testing is the wild west — every client/server pair has quirks.
graphql-ws against a real WebSocket transport, assert each event.graphql-ws protocol is the current standard (the legacy subscriptions-transport-ws is deprecated).Subscriptions are also the most likely area to skip and instead test via end-to-end UI flows. Be deliberate.
If your stack uses persisted queries (also called APQ — Automatic Persisted Queries), tests must either:
If your production traffic is APQ-only, your tests should be APQ-aware too. Otherwise you're testing a different code path than what runs in prod.
body.errors..graphql files plus graphql-codegen if possible.__typename everywhere in tests, but not in production — caches behave differently. Match how the client actually queries.When helping with GraphQL testing, ask:
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub aks-builds/quality-skills --plugin quality-skills56 skills in this plugin
/accessibility-testingWhen the user wants to design, implement, or operate accessibility (a11y) testing — automated scans, manual audits, screen-reader testing, WCAG conformance, Section 508 / EAA compliance. Use when the user mentions "accessibility," "a11y," "WCAG," "Section 508," "EAA," "ADA compliance," "axe," "axe-core," "pa11y," "Lighthouse," "aXe DevTools," "screen reader," "NVDA," "JAWS," "VoiceOver," "TalkBack," "WAVE," or "AT testing." For visual diff see visual-regression. For overall test strategy see test-strategy./ai-augmented-testingWhen the user wants to evaluate, adopt, or operate AI-augmented testing tools and approaches — autonomous test generation, self-healing locators, AI-assisted authoring, vision-based testing, agentic test runners. Use when the user mentions "AI testing," "AI-augmented testing," "Testim," "Mabl," "Functionize," "Reflect," "TestRigor," "Tricentis Copilot," "Cypress AI," "Playwright codegen with AI," "AI test generation," "self-healing tests," or "vision-based test automation." For LLM-product evals see llm-eval-testing. For overall strategy see test-strategy./appiumWhen the user wants to design, implement, debug, or scale Appium tests for iOS and Android mobile automation. Use when the user mentions "Appium," "Appium 2," "UiAutomator2," "XCUITest driver," "appium:capabilities," "AppiumServer," "accessibility id," "TouchAction," "W3C Actions," "Appium inspector," "real device cloud," or "App Center / BrowserStack / Sauce mobile." For Android-native frameworks see espresso. For iOS-native see xcuitest. For React Native specifically see detox. For YAML-driven mobile flows see maestro. For desktop web automation see selenium / playwright / webdriverio.