GraphQL Test Strategy Generator
Instructions
Act as a Senior QA Architect. Create a comprehensive GraphQL Test Strategy Document for a production-grade supergraph, written at a level of technical depth ready for engineering leadership review.
Step 1: Explore the Codebase
Before writing anything, gather the following context by reading relevant files:
- Schema: GraphQL schema file(s) or the code-first schema builder (e.g., Pothos, Nexus, type-graphql). Identify all types, queries, mutations, subscriptions, and field-level nullability.
- Existing tests: Any test files — note what is already covered and what tooling is used (Jest, Vitest, Bun test, etc.).
- Resolvers: How resolvers are implemented, whether DataLoaders are used, and where N+1 patterns may exist.
- Data sources: Databases, external APIs, in-memory packages. Note what serves as the "source of truth."
- Infrastructure/deployment: Deployment target (Cloudflare Workers, Lambda, Node.js server, etc.) and any resource constraints (memory limits, cold starts, rate limits).
- Security config: Auth plugins, depth limiting, query complexity, introspection settings, rate limiting.
- CI/CD: Existing GitHub Actions or pipeline config files to understand what already runs in CI.
- README / CLAUDE.md: For any domain-specific context or constraints already documented.
Step 2: Identify Risk Areas
Based on the codebase exploration, identify:
- Complexity hotspots: Deeply nested relationships that could exhaust memory or trigger N+1.
- Filter/input attack surface: Any user-supplied regex, nested input objects, or dynamic query building.
- Public contract surface: Fields/types that are consumed by external clients and must not break.
- Nullability gaps: Fields that should be nullable but are not (or vice versa) — these cause runtime errors.
- Missing coverage: Resolvers or edge cases with no existing tests.
Step 3: Generate TEST_STRATEGY.md
Write the document to the project root as TEST_STRATEGY.md. Use the following structure — include only sections relevant to the actual codebase; omit sections that don't apply:
# Test Strategy Document
## GraphQL API — Production-Grade Test Strategy
**Role:** Senior QA Architect
**Scope:** [describe the API and its public URL if known]
**Context:** [deployment target, schema builder, filter engine, resource constraints]
**Audience:** Engineering Leadership
---
## 0. Strategic Intent & Discovery
### 0.1 Discovery Questions
Write each as an explicit question. Follow each with: *Answer: [what was found and how it shaped testing].*
- Data integrity: how the source of truth is validated through schema transformations
- Resource constraints: what limits apply (memory, CPU, rate limits)
- Consumer safety: how breaking changes are prevented for public consumers
### 0.2 Priority Scenarios (Risk-Based)
List the 3–5 highest-risk scenarios with a concrete failure mode, severity rating (Critical / High / Medium), and blast radius.
### 0.3 Out of Scope & Trade-offs
Each exclusion must name the item, the reason for deferral (time / cost / feasibility), and the proxy signal that will substitute.
### 0.4 AI Methodology
Document the model used, the exact prompt, what the AI produced, and specific changes made during human review.
---
## 1. Schema Governance & Type Safety
Cover:
- Code-first vs SDL-first approach in this project
- Automated breaking change detection: tool used (graphql-inspector, Rover Subgraph Checks), CI integration, and exit criteria
- Schema snapshot testing for response structure regression
- Client code generation if applicable
- Schema linting rules (graphql-eslint)
---
## 2. Testing Levels
### 2.1 Unit Tests — Resolver Logic
- Extract complex logic from resolvers into standalone functions; test those directly with Jest or Bun test
- Cover: field splitting, type coercion, null guards, validation helpers
- Tooling: [name the test runner used in this project]
### 2.2 Integration Tests — Schema-Driven
- Execute full GraphQL operations against the in-memory server (yoga.fetch, Apollo test utils, etc.)
- Key scenarios: happy paths, nullability edge cases, filter combinations, error paths
- Snapshot testing: capture JSON response shapes and fail CI on structural drift
### 2.3 Contract Testing
- Schema diffing strategy (graphql-inspector diff against main/production)
- Exit criteria: zero breaking changes without explicit approval and version bump
### 2.4 End-to-End Tests — Critical Flows
- Define the 3–5 highest-value user flows that must work end-to-end
- Tooling: Playwright or Cypress against a deployed staging environment
- Trigger: pre-release gate only (not on every PR)
---
## 3. Security
Cover only what is relevant to the actual schema and deployment:
- **Introspection**: disabled in production (`NODE_ENV=production`), enabled for authenticated developers in non-production
- **Query depth limiting**: hard limit value and plugin used (e.g., `useDepthLimit({ maxDepth: N })`)
- **Query complexity analysis**: cost budget, plugin used (e.g., `graphql-query-complexity`), and what triggers a block
- **Rate limiting**: requests/minute threshold and enforcement layer (CDN, middleware, or plugin)
- **ReDoS prevention**: validation applied to user-supplied regex inputs before execution
- **Field-level authorization**: scope-based plugin and which fields are gated (if auth is present)
---
## 4. Performance
- **N+1 detection**: how N+1 patterns are identified in tests (query counts, tracing assertions)
- **DataLoader strategy**: which resolvers use DataLoaders, batching window, and cache scope
- **Load testing**: tool (k6, Artillery), target throughput, and latency thresholds for critical queries
- **Cache verification**: how cache-hit rates are validated (headers, tracing, or observability tooling)
- **Observability**: tracing and monitoring tooling (Apollo GraphOS, Stellate, or equivalent)
---
## 5. Automation & CI/CD
### 5.1 Exit Criteria for Release
List concrete, measurable gates with current status:
| Gate | Target | Status |
### 5.2 Workflow Steps
Ordered list of CI steps grounded in the actual pipeline config. Recommended order:
1. Lint & type check
2. Schema diff (breaking change detection)
3. Unit & integration tests
4. Schema snapshot validation
5. Security checks (depth, complexity, ReDoS fuzz)
6. E2E tests (staging, pre-release only)
---
## 6. Tooling Recommendations
List the recommended tools per concern, distinguishing between currently in use and recommended additions:
| Concern | Tool | Status |
|---|---|---|
| Functional testing | Jest / Bun test | [In use / Recommended] |
| Schema validation | graphql-inspector or Rover | [In use / Recommended] |
| Monitoring & tracing | Apollo GraphOS | [In use / Recommended] |
| Load testing | k6 or Artillery | [In use / Recommended] |
| E2E | Playwright | [In use / Recommended] |
| Query complexity | graphql-query-complexity | [In use / Recommended] |
---
## 7. Implementation Checklist
### Already Implemented
Use `[x]` only for items verified against the source (cite file:line).
### Recommended (Not Yet Implemented)
Use `[ ]` for all items not confirmed in source. Do not guess.
Step 4: Review Before Saving
Before writing the file:
- Confirm every
[x] checklist item by citing the specific file and line number that implements it. If you cannot verify it, mark it [ ].
- Remove any section that has no real content for this project — do not pad with placeholder text.
- Ensure all resource constraints (memory limits, CPU budgets, rate limits) are specific numbers sourced from config files, not generic placeholders.
- Security and performance sections must reflect only what is found or concretely recommended for this codebase — not generic industry patterns.
- Tone must be technical and precise, suitable for an engineering leadership review.
Write the final document to TEST_STRATEGY.md in the project root.
Source: denaliweb123-oss/countries — distributed by TomeVault.
1---2name: graphql-test-strategy3description: Analyzes a GraphQL API codebase and generates a production-grade TEST_STRATEGY.md covering testing levels, performance, security, automation, and tooling. Use when starting a new GraphQL project, preparing for a QA audit, or formalizing testing practices for engineering leadership review.4---56# GraphQL Test Strategy Generator78## Instructions910Act as a Senior QA Architect. Create a comprehensive GraphQL Test Strategy Document for a production-grade supergraph, written at a level of technical depth ready for engineering leadership review.1112### Step 1: Explore the Codebase1314Before writing anything, gather the following context by reading relevant files:1516- **Schema**: GraphQL schema file(s) or the code-first schema builder (e.g., Pothos, Nexus, type-graphql). Identify all types, queries, mutations, subscriptions, and field-level nullability.17- **Existing tests**: Any test files — note what is already covered and what tooling is used (Jest, Vitest, Bun test, etc.).18- **Resolvers**: How resolvers are implemented, whether DataLoaders are used, and where N+1 patterns may exist.19- **Data sources**: Databases, external APIs, in-memory packages. Note what serves as the "source of truth."20- **Infrastructure/deployment**: Deployment target (Cloudflare Workers, Lambda, Node.js server, etc.) and any resource constraints (memory limits, cold starts, rate limits).21- **Security config**: Auth plugins, depth limiting, query complexity, introspection settings, rate limiting.22- **CI/CD**: Existing GitHub Actions or pipeline config files to understand what already runs in CI.23- **README / CLAUDE.md**: For any domain-specific context or constraints already documented.2425### Step 2: Identify Risk Areas2627Based on the codebase exploration, identify:28291. **Complexity hotspots**: Deeply nested relationships that could exhaust memory or trigger N+1.302. **Filter/input attack surface**: Any user-supplied regex, nested input objects, or dynamic query building.313. **Public contract surface**: Fields/types that are consumed by external clients and must not break.324. **Nullability gaps**: Fields that should be nullable but are not (or vice versa) — these cause runtime errors.335. **Missing coverage**: Resolvers or edge cases with no existing tests.3435### Step 3: Generate TEST_STRATEGY.md3637Write the document to the project root as `TEST_STRATEGY.md`. Use the following structure — include only sections relevant to the actual codebase; omit sections that don't apply:3839```markdown40# Test Strategy Document41## GraphQL API — Production-Grade Test Strategy4243**Role:** Senior QA Architect44**Scope:** [describe the API and its public URL if known]45**Context:** [deployment target, schema builder, filter engine, resource constraints]46**Audience:** Engineering Leadership4748---4950## 0. Strategic Intent & Discovery5152### 0.1 Discovery Questions53Write each as an explicit question. Follow each with: *Answer: [what was found and how it shaped testing].*54- Data integrity: how the source of truth is validated through schema transformations55- Resource constraints: what limits apply (memory, CPU, rate limits)56- Consumer safety: how breaking changes are prevented for public consumers5758### 0.2 Priority Scenarios (Risk-Based)59List the 3–5 highest-risk scenarios with a concrete failure mode, severity rating (Critical / High / Medium), and blast radius.6061### 0.3 Out of Scope & Trade-offs62Each exclusion must name the item, the reason for deferral (time / cost / feasibility), and the proxy signal that will substitute.6364### 0.4 AI Methodology65Document the model used, the exact prompt, what the AI produced, and specific changes made during human review.6667---6869## 1. Schema Governance & Type Safety7071Cover:72- Code-first vs SDL-first approach in this project73- Automated breaking change detection: tool used (graphql-inspector, Rover Subgraph Checks), CI integration, and exit criteria74- Schema snapshot testing for response structure regression75- Client code generation if applicable76- Schema linting rules (graphql-eslint)7778---7980## 2. Testing Levels8182### 2.1 Unit Tests — Resolver Logic83- Extract complex logic from resolvers into standalone functions; test those directly with Jest or Bun test84- Cover: field splitting, type coercion, null guards, validation helpers85- Tooling: [name the test runner used in this project]8687### 2.2 Integration Tests — Schema-Driven88- Execute full GraphQL operations against the in-memory server (yoga.fetch, Apollo test utils, etc.)89- Key scenarios: happy paths, nullability edge cases, filter combinations, error paths90- Snapshot testing: capture JSON response shapes and fail CI on structural drift9192### 2.3 Contract Testing93- Schema diffing strategy (graphql-inspector diff against main/production)94- Exit criteria: zero breaking changes without explicit approval and version bump9596### 2.4 End-to-End Tests — Critical Flows97- Define the 3–5 highest-value user flows that must work end-to-end98- Tooling: Playwright or Cypress against a deployed staging environment99- Trigger: pre-release gate only (not on every PR)100101---102103## 3. Security104105Cover only what is relevant to the actual schema and deployment:106- **Introspection**: disabled in production (`NODE_ENV=production`), enabled for authenticated developers in non-production107- **Query depth limiting**: hard limit value and plugin used (e.g., `useDepthLimit({ maxDepth: N })`)108- **Query complexity analysis**: cost budget, plugin used (e.g., `graphql-query-complexity`), and what triggers a block109- **Rate limiting**: requests/minute threshold and enforcement layer (CDN, middleware, or plugin)110- **ReDoS prevention**: validation applied to user-supplied regex inputs before execution111- **Field-level authorization**: scope-based plugin and which fields are gated (if auth is present)112113---114115## 4. Performance116117- **N+1 detection**: how N+1 patterns are identified in tests (query counts, tracing assertions)118- **DataLoader strategy**: which resolvers use DataLoaders, batching window, and cache scope119- **Load testing**: tool (k6, Artillery), target throughput, and latency thresholds for critical queries120- **Cache verification**: how cache-hit rates are validated (headers, tracing, or observability tooling)121- **Observability**: tracing and monitoring tooling (Apollo GraphOS, Stellate, or equivalent)122123---124125## 5. Automation & CI/CD126127### 5.1 Exit Criteria for Release128List concrete, measurable gates with current status:129| Gate | Target | Status |130131### 5.2 Workflow Steps132Ordered list of CI steps grounded in the actual pipeline config. Recommended order:1331. Lint & type check1342. Schema diff (breaking change detection)1353. Unit & integration tests1364. Schema snapshot validation1375. Security checks (depth, complexity, ReDoS fuzz)1386. E2E tests (staging, pre-release only)139140---141142## 6. Tooling Recommendations143144List the recommended tools per concern, distinguishing between currently in use and recommended additions:145| Concern | Tool | Status |146|---|---|---|147| Functional testing | Jest / Bun test | [In use / Recommended] |148| Schema validation | graphql-inspector or Rover | [In use / Recommended] |149| Monitoring & tracing | Apollo GraphOS | [In use / Recommended] |150| Load testing | k6 or Artillery | [In use / Recommended] |151| E2E | Playwright | [In use / Recommended] |152| Query complexity | graphql-query-complexity | [In use / Recommended] |153154---155156## 7. Implementation Checklist157158### Already Implemented159Use `[x]` only for items verified against the source (cite file:line).160161### Recommended (Not Yet Implemented)162Use `[ ]` for all items not confirmed in source. Do not guess.163```164165### Step 4: Review Before Saving166167Before writing the file:168- Confirm every `[x]` checklist item by citing the specific file and line number that implements it. If you cannot verify it, mark it `[ ]`.169- Remove any section that has no real content for this project — do not pad with placeholder text.170- Ensure all resource constraints (memory limits, CPU budgets, rate limits) are specific numbers sourced from config files, not generic placeholders.171- Security and performance sections must reflect only what is found or concretely recommended for this codebase — not generic industry patterns.172- Tone must be technical and precise, suitable for an engineering leadership review.173174Write the final document to `TEST_STRATEGY.md` in the project root.175176---177> Source: [denaliweb123-oss/countries](https://github.com/denaliweb123-oss/countries) — distributed by [TomeVault](https://tomevault.io).178<!-- tomevault:4.0:skill_md:2026-06-15 -->