typescript-operations and client-preset v6 are now available, introducing a major overhaul of how client types are generated.
- Significantly less generated code
- Stronger, more accurate types by default
- Fewer dependencies and a simpler setup
This release is the result of close collaboration between The Guild and Igor Kusakov from Yelp, along with thoughtful input from the wider GraphQL community.
Feel free to reach out with ideas or feedback: X, LinkedIn, GraphQL Discord
The main change
Previously, the low-level typescript plugin generated all schema types, and typescript-operations referenced those types for inputs and variables.
This approach caused a few issues:
- All schema types were generated, even if unused
Result: large generated files filled with types you never use - Client and server plugins were indirectly coupled
Result: slower iteration, as changes risked breaking other use cases typescript-operationssetups were manual and easy to get wrong
Result: verbose setups and reliance on additional plugins or presets
With v6, typescript-operations and client-preset are redesigned around three key ideas:
- Generate schema types only when they are actually used, instead of generating the entire schema upfront
- Fully decouple from
typescriptandtypescript-resolvers - Provide better built-in support for common
typescript-operationssetups: one-file, multi-file, and near-operation-file
Read about the supported typescript-operations setups
client-preset
is our recommended setup thanks to its simplicity and flexibility. It builds
on the improved typescript-operations under the hood, so you get all its
benefits out of the box, with no extra setup.
Other notable changes
- Default
client-presetpersisted document hash algorithm is now SHA-256 - Improved type correctness and defaults for scalars,
@skip/@include, and field nullability - Configuration updates: improved
avoidOptionals,enumValues, and removal ofpreResolveTypes - CLI errors no longer fail silently
- Packages are ESM-first
Read the v6 migration guide
Bonus: migrating from Apollo Tooling
GraphQL Codegen now supports migration from Apollo Tooling (apollo client:codegen).
This includes:
near-operation-filepreset compatibility- Enum type compatibility
- Matching type naming conventions
Existing Apollo Tooling projects can switch with minimal changes.
Read the migration guide from Apollo Tooling
