Direct answer
GraphQL Code Generator runs a configurable pipeline that reads schemas and GraphQL documents and emits typed output, and client presets shape that output for a specific client workflow. A generated type is a function of three inputs: which schema sources were loaded, which document globs were matched, and which preset settings were applied. A generated diff you cannot trace to one of those inputs is a diff you should not accept, because the next generation will reproduce whatever produced it. The concrete win is a generated boundary you can explain line by line: this type came from that schema, that operation came from that document. The concrete loss is that generated types compiling is not proof the queries are correct against the runtime schema, and a preset change can reshape output across every matched document at once.
Start with schema, documents, and preset before the diff. The generated files are the last thing to review, not the first.
Why an unexplained type diff costs a review cycle
Generated types change in bulk. A schema edit adds a field and every operation selecting it changes. A document glob starts matching a new file and a whole operation surface appears. A preset setting flips and naming, nullability wrappers, or hook signatures change across the codebase. Any of these can produce a diff that looks like a bug and is actually a correct consequence of an input.
Three costs follow from reviewing generated output without its inputs. Review time balloons because a reviewer reads hundreds of generated lines to find the one input that caused them. Correctness risk goes up when a reviewer approves a diff by trusting the generator, because the generator produces what the inputs say, not what the runtime API serves. Ownership gets blurry because nobody wrote the generated types, so nobody feels responsible for explaining them.
Reading inputs first reverses all three. The diff becomes a consequence to confirm rather than a mystery to solve. This post stays on tracing generated types to their sources, and it does not turn preset review into prompting or tool-use guidance.
What the Client Preset Owns
A preset is a bundle of configuration for a specific client workflow. Rather than configuring individual plugins for each output, a preset packages the plugin selection, naming conventions, and output structure for a target. The client preset is the one this post reviews, and the generator documentation describes presets for specific client workflows.
| Preset responsibility | What it decides | What it does not decide |
|---|---|---|
| Plugin selection | Which output types are generated | Whether your schema is valid |
| Naming conventions | How types and hooks are named | What the runtime API returns |
| Output structure | Which files hold which output | How your bundler resolves them |
| Document handling | How operations map to generated code | Whether an operation is correct |
Official, F049: GraphQL Code Generator documents a configurable pipeline that consumes schemas and GraphQL documents to produce typed output, with presets for specific client workflows. The configuration and preset pages were not fetched in this pass, so current preset names and options should be verified before relying on a fine detail.
The table works as ownership map. The preset owns the shape of the output. The preset does not own the truth of the input, and that distinction is the whole review discipline. The OpenAPI generator customization guide applies the same split to a different generator: generated output is a function of recorded inputs, and the inputs are where fixes belong.
Read Schema Sources
Schema sources are the definitions the pipeline type-checks documents against. A schema can come from a local file, a URL, a federated composition output, or several of these at once. Which sources are loaded decides what types exist in the generated output.
schema:
- ./schema.graphql
- './src/**/*.graphql'
# a second source adds types the first does not defineThe review question for schema sources is authority. Which source defines a type when two sources both mention it? A stale local schema next to a fresh URL source can produce output that describes an API the server no longer serves. Recording each source and its role is the cheapest way to keep that question answerable.
| Schema source | Role | Review question |
|---|---|---|
| Local schema file | Authoritative definitions | Is it at the version consumers expect? |
| Local operation files | Schema fragments defined in code | Do they duplicate a server type? |
| URL source | Live introspection | Is the environment the right one? |
| Composition output | Federation result | Does it match the deployed graph? |
Use the table as authority inventory. Every type in the generated output traces to one of these rows, and a type whose authority is ambiguous is the type most likely to be wrong in a way that compiles.
Map Document Globs
Document globs decide which operations the pipeline reads. A glob that matches a file pulls every operation in that file into the generated output. A glob that stops matching a file makes its operations vanish from generation, and the code that used the generated types stops compiling.
documents:
- './src/queries/**/*.graphql'
- './src/mutations/**/*.graphql'
# a glob that stops matching a file removes its operations from outputThe review question for globs is coverage. Does the glob match every operation the application actually sends, and does it match nothing it should not? A too-narrow glob silently omits operations, which means their types are never generated and type errors appear at the call site rather than at generation. A too-wide glob pulls in test fixtures or deprecated operations and inflates the diff.
| Glob shape | What it matches | Failure mode |
|---|---|---|
./src/**/*.graphql |
Every GraphQL file under src | Pulls in fixtures or experiments |
./src/queries/*.graphql |
Only top-level query files | Misses nested operation files |
| Two overlapping globs | Files matched twice | Duplicate output or confusing diffs |
| Glob that lost a path | Nothing for a moved directory | Operations disappear from output |
Derived, F050: Identifying which schema source, document glob, or preset setting changed before accepting a generated diff is an editorial review method. The method is a recommendation built on the generator’s input model, not evidence that generated operations match runtime behavior.
A glob change is a contract change for the same reason a schema change is. The TypeScript project references guide makes the parallel explicit for build graphs: an edge added for convenience is still an edge the build has to honor, and a glob that matches a new directory is still a decision someone has to own.
Inspect Preset Configuration
Preset configuration is the third input, and it is the one that changes output without touching the schema or the documents. Naming, nullability handling, and how operations map to generated hooks or functions are all preset decisions.
| Preset setting area | Shapes | Diff signature when changed |
|---|---|---|
| Naming | Type and hook names | Renames across many files |
| Nullability | Optional and required wrappers | Wrapper changes on fields |
| Operation mapping | How a document becomes a hook | Signature changes on generated functions |
| Output files | Which files hold what | File additions or removals |
Every row of the table is diagnostic. A diff that renames types everywhere points at naming configuration. A diff that changes wrappers points at nullability handling. A diff that adds or removes files points at output structure. Matching the signature to the setting area is how a large diff becomes a one-line explanation. Because the preset pages were not fetched in this pass, this post does not enumerate exact setting names or claim defaults. The config reference at the-guild.dev and the presets overview at the presets page are the references to check for current names. The client preset page and the React and Vue guide cover framework-specific output, and whether your client preset emits hooks or plain functions is a property of that configuration rather than a universal.
Separate Generated and Custom Files
The output directory contains generated files and, in many setups, custom files written by hand. Keeping the two separated is what makes a generated diff reviewable, because a diff that mixes hand-written code with regenerated output cannot be attributed.
| File kind | Status | Change policy |
|---|---|---|
| Generated types | Output of the pipeline | Do not edit; regenerate |
| Generated hooks or functions | Output of the pipeline | Do not edit; change preset or documents |
| Custom wrapper code | Source | Review like any source file |
| Custom scalar mappings | Source, referenced by config | Review with the config change |
The generated-code rule this batch applies repeatedly is worth restating here. Claude Code’s best practices say not to edit generated output. The same rule covers generated GraphQL types: the fix for a wrong type is in the schema, the document, or the preset, not in the emitted file. The C# source generators guide applies the identical discipline to compiler output, and the sqlc query annotations guide applies it to SQL-generated functions.
Custom wrapper code is where hand-written behavior belongs. A wrapper around a generated hook can add error handling, caching, or logging, and it survives regeneration because it is source. The wrapper is also where the honest loss of generated types shows up: the wrapper’s correctness is your responsibility, and generated types do not certify it.
Regenerate from Reviewed Inputs
A reproducible generation starts from reviewed inputs. The schema sources are at recorded states, the document globs match the intended set, and the preset configuration is committed before the generation command runs.
git status --porcelain
# confirm schema, documents, and config are committed
npx graphql-codegen
# regenerate from the reviewed inputs
git diff --stat
# inspect the shape of the generated diffThe known-input rule is what makes the diff meaningful. A generation run against uncommitted schema edits produces a diff nobody can attribute, and the fix is to commit the input change first so the generated consequence is a separate, reviewable step.
| Precondition | Check | Why it matters |
|---|---|---|
| Schema committed | Schema sources at a known state | The diff traces to a schema change |
| Documents committed | Matched operations at a known state | Operation changes are attributable |
| Preset config committed | Configuration at a known state | Preset changes are attributable |
| No generated edits pending | Output directory clean of hand edits | Hand patches do not pollute the diff |
Regeneration is also the cheapest way to test an input change. Change the input, run generation, and the diff is the review. The Claude Code common workflows cover iterating an edit against a command, and generation is exactly that loop. The Claude Code best practices favor a check that returns pass or fail, and for generated types the check is a clean regeneration plus a consumer build.
Explain the Generated Diff
A generated diff review has one question per hunk: which input produced this? Schema changes produce field-level changes. Document changes produce operation-level changes. Preset changes produce cross-cutting naming, wrapper, or file changes. Matching the hunk to the input is the whole skill.
| Hunk pattern | Likely input | Review action |
|---|---|---|
| New field on a type | Schema change | Confirm the schema change was intended |
| New operation types | Document added or glob widened | Confirm the operation is meant to be generated |
| Renamed types or hooks | Preset naming change | Confirm the rename is a decision |
| Wrapper changes on fields | Preset nullability change | Confirm nullability matches the runtime |
| Files added or removed | Preset output structure change | Confirm the file layout is intended |
Approach the table as matching exercise. Every hunk should land in a row, and a hunk that matches no row is either a hand edit or an input nobody recorded. Both are findings before merge. The pass condition is concrete. Every hunk traces to a recorded input, and the application that uses the generated types compiles. Compiling is necessary and it is not sufficient. Generated types are a projection of the schema and documents at generation time. Whether the operations are correct against the runtime API is a separate question that needs its own evidence, and this post does not claim generated types prove query correctness.
Schema source inventory
A schema inventory is the artifact worth keeping from a review. Each row records a source, its role, and its authority, so the next generated diff can be traced without re-deriving the input model.
| Source | Kind | Authority | Notes |
|---|---|---|---|
schema.graphql |
Local definition | Authoritative for server types | Versioned with the service |
src/**/*.graphql |
Local operations | Authoritative for client operations | Matched by the documents glob |
| Introspection URL | Live source | Authoritative for the deployed graph | Environment-specific |
| Composition output | Federation result | Authoritative for the federated graph | Must match deployment |
Read the inventory as an authority map. Every generated type traces to a row, and the rows where authority is shared or ambiguous are the ones worth a second look. A schema that comes from a URL in one environment and a file in another can produce output that is correct in one place and wrong in another, and the inventory is how that difference becomes visible before it ships.
The same authority question shows up in other generated-code posts in this batch. Protocol Buffer Reserved Fields covers schema authority for wire compatibility, and Django Deprecation Runway covers using release notes as the authority for what an API will stop providing.
Document glob to operation inventory
A glob inventory is the artifact that makes a document change attributable. Each row records a glob, what it matches, and how many operations it pulls into generation. Without it, a disappearing operation is a mystery; with it, the mystery is a lookup.
find ./src -name '*.graphql' | sort
# list every file a broad glob could match
grep -rc 'query |mutation |subscription ' ./src --include='*.graphql'
# count operations per fileTwo commands produce a coverage picture. The find lists every candidate file. The grep counts operations per file. Comparing the two against the configured globs is the check that catches both failure modes: an operation the application sends that no glob matches, and a file a glob matches that should not be generated.
| File | Operations | Matched by | Review note |
|---|---|---|---|
src/queries/orders.graphql |
3 queries | ./src/queries/**/*.graphql |
Intentional |
src/mutations/cart.graphql |
2 mutations | ./src/mutations/**/*.graphql |
Intentional |
src/__fixtures__/sample.graphql |
1 query | broad glob would match | Exclude or narrow the glob |
src/experiments/trial.graphql |
1 query | broad glob would match | Exclude until it ships |
The table works as coverage audit. The two rows that say exclude are the reason a narrow glob is usually the better default. A broad glob is convenient until the day an experiment file generates types that a reviewer has to explain. The inventory also makes the diff conversation concrete. When a generated operation disappears, the inventory answers whether the file moved, whether the glob narrowed, or whether the operation was deleted. Each answer points at a different input, and only one of them is usually intended. Recording the inventory next to the schema authority map gives a reviewer two axes for the whole generated surface: which types exist and which operations exist, each traced to the input that produced them.
Preset setting and output boundary matrix
The preset is the input most likely to change output without anyone touching the schema or documents. A matrix of setting areas against their output boundary is the review aid that keeps a cross-cutting preset change explainable.
| Setting area | Output boundary it shapes | Hunk signature | Input that produced it |
|---|---|---|---|
| Naming | Type and hook identifiers | Renames across every matched operation | Preset naming configuration |
| Nullability | Optional and required wrappers | Wrapper changes on fields across types | Preset nullability handling |
| Operation mapping | How a document becomes a hook or function | Signature changes on generated functions | Preset operation configuration |
| Output files | Which files hold which output | Files added or removed across the output | Preset output structure |
| Scalars | How custom scalars map to language types | Mapping changes wherever a scalar appears | Preset scalar configuration |
Use the matrix as a diagnostic table for the preset axis. A generated diff has three possible input axes, and the preset is the one that produces the widest changes per line of configuration. That asymmetry is worth respecting in review: a one-line preset change can outproduce a large schema edit, and the reviewer who knows that checks the preset configuration before reading the diff line by line. The matrix also explains why preset changes and schema changes should not ship in the same generation. A diff that mixes a schema field addition with a preset naming change is two decisions in one review, and attributing it requires untangling which hunks came from which axis. Running them as separate generations with separate diffs keeps each review honest, and the cost is one extra generation run.
The concrete win, loss, and implication
The concrete win is a generated diff you can attribute. When a reviewer asks why a hook signature changed, the answer is a preset setting, a schema commit, or a document change with a recorded reason. That answer survives regeneration, because the reasoning lives in an input rather than in an emitted file.
The concrete loss is that a preset change reshapes output everywhere at once. A naming or nullability change touches every matched operation, and the diff is large by construction. The cost is review attention: a large generated diff is where a real bug hides most easily, because reviewers stop reading carefully after the first hundred similar lines.
The practical implication is that generated types are a consequence, not a source. Teams that review inputs before the diff spend less time approving changes nobody can explain. Teams that approve generated output by trusting the generator keep discovering the same runtime mismatch after a schema and the code disagree.
Working with Claude Code on a generated diff
Give the agent three inputs: the change you want in the generated output, the commands it may run, and the definition of done. The definition of done excludes editing generated files. Ask for a regeneration against committed inputs and a diff review that attributes each hunk to a schema source, a document glob, or a preset setting.
npx graphql-codegen
# ask for a clean regeneration before reviewing any diff
git diff --stat
# ask for the diff shape, then attribute each groupReview the agent’s attribution claim. The agent can read the diff accurately and still propose editing a generated file, because that is the shortest path to a passing type check. Deciding whether a change belongs in the schema, the documents, or the preset is a design decision, and the reviewer owns it. The Claude Code verification guide covers what to ask before accepting the change.
A generated diff that turns into a wide reformat is worth pausing on. The Claude Code overengineering guide describes that pattern, and a preset change is one of its triggers. Where generated tests are the oracle, the Claude Code generated tests oracle bias guide covers why a green check against generated expectations is not proof against the runtime.
Checklist before you accept a generated diff
| Check | Pass condition | If it fails |
|---|---|---|
| Schema sources recorded | Each source and its authority written down | Build the inventory before reviewing |
| Document globs recorded | The matched operation set is named | Read the globs and list matches |
| Preset settings recorded | Configuration committed and described | Read the preset configuration |
| Inputs committed | Schema, documents, and config at known states | Commit inputs before regenerating |
| No generated edits | Output directory clean of hand edits | Regenerate cleanly and re-review |
| Hunks attributed | Every hunk matches an input row | Trace the hunk or reject the diff |
| Consumers compile | Code using the generated types type-checks | Fix at the input, not the output |
| No correctness claim | Nobody claims generated types prove query correctness | Add a runtime check if correctness matters |
Data gap and future update
The GraphQL Code Generator repository was fetched, and the configuration and preset pages are the references used for the input model. Those pages were not fetched in this pass, so exact preset names, setting names, and defaults should be verified against the current documentation before relying on a fine detail. F049 is official in its broad claim and F050 is derived, and neither is presented as a vendor guarantee about output correctness.
No generation-time measurement, output-size number, or correctness rate is reported here, because none was measured. A future update quantifying how a preset change affects generated file size or type-check time for a specific project would need a fixed generator version and a measured pass. No such data was collected.
Whether a specific client preset emits hooks, plain functions, or framework-specific wrappers is a property of that configuration, and this post does not enumerate them. The React and Vue guide is the reference for framework-specific output, and each framework’s current behavior should be checked there.
Related reading on generated-code boundaries
Generated output is a recurring boundary in this batch. OpenAPI Generator Customization covers tracing a client diff to a spec, config, or template input. sqlc Query Annotations covers aligning SQL and generated types at the query level. C# Source Generators covers reviewing compiler-emitted contracts. Protocol Buffer Reserved Fields covers schema compatibility for generated bindings.
Build and dependency boundaries appear in TypeScript Project References, pnpm Peer Diagnostics, and Cargo Build Scripts. Dependency selection appears in Gradle Constraints vs Dependencies, Gradle Variant Attributes, and Maven Optional Dependencies.
Framework maintenance and upgrade sequencing appear in Django Deprecation Runway, Rails Upgrade Sequence, and Angular Update Guide. Input ownership beyond generated clients appears in Python Dependency Groups vs Extras, NuGet Central Package Management, and Cargo Workspace Inheritance.
More from this batch
- pnpm Peer Diagnostics: Read Resolution Reports Before Claude Code Pins
- TypeScript Project References: A Claude Code Boundary Guide
- OpenAPI Generator Customization: Keep Templates and Config in Sync
- Protocol Buffer Reserved Fields: A Claude Code Wire Compatibility Guide
- sqlc Query Annotations: Align SQL and Generated Types With Claude Code
- Django Deprecation Runway: Plan Framework Maintenance With Claude Code
- Rails Upgrade Sequence: Order Major Changes With Claude Code
- Angular Update Guide: Build a Migration Plan With Claude Code
- C# Source Generators: Review Generated Contracts With Claude Code
- Python TypedDict Boundaries: Stop Model Drift With Claude Code
One AI API Key option for OpenAI-format agents
Claude Code uses an Anthropic-format route, so the One AI free model IDs are not a Claude Code model source. The packet records Claude IDs as unavailable on 2026-11-27.
OpenAI-format agents have a separate route: One AI API Key offers https://api.oneaiapikey.com/v1, one key, and 46 live free IDs. That is a different client and request format, not a workaround for Claude Code authentication. Check the free model list before choosing an agent route, or read the quickstart for the request shape.
FAQ
Can I fix a wrong generated type by editing the generated file?
No. The generated file is pipeline output, and the next generation replaces it. The fix belongs in the schema, the document, or the preset setting that produced the type. Editing the output hides the input problem until regeneration erases the edit.
How do I tell whether a diff came from a schema change or a preset change?
Schema changes produce field-level changes tied to the type that changed. Preset changes produce cross-cutting patterns: renames everywhere, wrapper changes on many fields, or files added and removed across the output. Match the pattern to the input area before proposing a fix.
Does a green type-check prove my queries are correct?
No. Generated types type-check your queries against the schema and documents you gave the generator. Whether those queries are correct against the runtime API depends on the schema sources being current and authoritative. A stale schema produces types that check cleanly and still describe an API the server no longer serves.
A document glob stopped matching a file and its types disappeared. Is that a bug?
Generated output is the consequence. The glob decides which operations the pipeline reads, and a file it no longer matches contributes no operations. Check whether the file moved or the glob narrowed, and treat the glob change as the input that caused the diff rather than patching the generated output.
What proves a preset change is complete?
Three conditions. Inputs are committed, every diff hunk traces to a recorded input, and the application using the generated types compiles. A green generation command alone is not a pass, because it says nothing about whether the reshaped output matches what the application expects.
More Claude Code troubleshooting
- Python Protocols vs ABCs: Preserve Interface Contracts With Claude Code
- Python Stub Drift: Audit Third-Party Types With Claude Code
- Go Module Compatibility: Keep API Changes Inside the Contract
- Go Workspace Boundaries: Decide What Belongs in go.work
- Go Module Graph Pruning: Explain Indirect Dependencies With Claude Code
- Cargo Feature Unification: Control Optional APIs With Claude Code
- Cargo Profile Boundaries: Keep Debug and Release Behavior Aligned
- Gradle Capability Conflicts: Resolve Competing Components With Claude Code
- .NET Multi-Targeting: Separate Framework Dependencies for Claude Code
- CMake Presets: Give Claude Code Reproducible Configure Inputs
- CMake find_package vs FetchContent: Choose a Dependency Boundary
- Conan CMakeDeps: Keep Consumer Targets Stable for Claude Code
Sources
- Official: GraphQL Code Generator Official Repository, reference for the generator project and its documentation set.
- Official: GraphQL Code Generator Config Reference, describing the configurable pipeline and presets for client workflows (F049). Page not fetched this pass.
- Official: GraphQL Code Generator Presets, reference for preset configuration (F050 context). Page not fetched this pass.
- Official: GraphQL Code Generator Client Preset, reference for the client preset output shape.
- Official: GraphQL Code Generator React and Vue Guide, reference for framework-specific generated output.
- Official: Claude Code Docs: Best Practices, supporting the rule against editing generated output.