GraphQL Codegen typescript-operations and client-preset v6 was released with a hollistic review of dependencies, config options, and plugin interoperability to improve Developer Experience for our users:
- Less generated code
- Better type correctness and defaults
- Fewer dependencies, and simpler setup
What changed?
Previously, the low-level typescript plugin was used to generate all schema types, and the typescript-operations plugin referred to the schema types in its Input and Variables types. This approach led to a few problems:
- All schema types were generated, even if unused
- Impact: Unncessarily large generated files and extraneous types, which caused confusion to users.
- Client and server plugins were indirectly tied together
- Examples:
typescriptplugin's default options were created to work for both client and server, but not optimised for either. This meant users must eventually tweaked the default config for their client use case.- Any attempt to reduce the generated schema types most likely touch the
typescriptplugin, which impacted the server plugintypescript-resolvers, because they both relied on the same generated type.
- Impact: Slower feature turnaround, because contributors working on the client use case needed to tip-toe to avoid impacting the server use case.
- Examples:
- Ways to setup Codegen config were numerous, with some requiring external plugins/presets with fragile integration
- Impact: Verbose Codegen config, added dependencies to maintain e.g. import-types preset
Now, typescript-operations and client-preset v6 were built with fundamental changes to solve the mentioned problems:
- Generates schema types only when used
- Fully decoupled from
typescriptandtypescript-resolvers - Built-in support for setups commonly used by the community: one-file, multi-file, near-operation-file setups
Other changes - TODO
- ESM dependencies
client-preset's default hash algorithm is SHA256
