|
| 1 | +--- |
| 2 | +title: GraphQL Code Generator Major Update, September 2025 |
| 3 | +authors: eddeee888 |
| 4 | +tags: [graphql, graphql-codegen, resolvers, federation] |
| 5 | +date: 2025-09-07 |
| 6 | +description: |
| 7 | + GraphQL Code Generator September 2025 update comes with improvements to Federation and normal |
| 8 | + GraphQL server typing and lots of internal quality-of-life changes. |
| 9 | +--- |
| 10 | + |
| 11 | +GraphQL Code Generator just released a major update to improve type correctness and usability for |
| 12 | +both Federation and standard GraphQL server architecture. This milestone, the result of a 9-month |
| 13 | +long journey, closes many long-standing reported issues and serves as the foundation to help us move |
| 14 | +forward faster. |
| 15 | + |
| 16 | +## Migration Guide |
| 17 | + |
| 18 | +- Federation entity's resolver types correctly reflect the parent may come from a different subgraph |
| 19 | + (via `__resolveReference`) or from the same subgraph. Use `mappers` to explicitly set the expected |
| 20 | + use case to help with typing. For example: |
| 21 | + |
| 22 | +```ts |
| 23 | +// If you are only resolving fields through `__resolveReference`, then explicitly set the reference type: |
| 24 | +import { FederationReferenceTypes } from "./types.generated"; |
| 25 | +export type UserMapper = FederationReferenceTypes["User"] |
| 26 | + |
| 27 | +// If your current subgraph returns a different interface to `__resolveReference`, include both in the mapper, and handle both cases in subsequent resolvers: |
| 28 | +import { UserTypeFromDatabase } from "./your-database-type"; |
| 29 | +import { FederationReferenceTypes } from "./types.generated"; |
| 30 | +export type UserMapper = |
| 31 | + | UserTypeFromDatabase |
| 32 | + | FederationReferenceTypes["User"] |
| 33 | + |
| 34 | +// If you want to standardise the mapper interface (which means you may need to resolve for `UserTypeFromDatabase` in `__resolveReference`): |
| 35 | +import { UserTypeFromDatabase } from "./your-database-type"; |
| 36 | +export type UserMapper = UserTypeFromDatabase |
| 37 | +``` |
| 38 | +
|
| 39 | +- If you have implemented non-meta resolvers in Interfaces, remove them as they are never called. |
| 40 | + Generated types have been updated to reflect this. |
| 41 | +- If you have implemented `__isTypeOf` resolvers for types that are not Interface implementing types |
| 42 | + or Union member types, remove them as they are never called. Generated types have been updated to |
| 43 | + reflect this. |
| 44 | +
|
| 45 | +## Breaking Changes |
| 46 | +
|
| 47 | +- `FederationReferenceTypes` is generated instead of inlining `__resolveReference` types to improve |
| 48 | + usability with mappers |
| 49 | +- Fixed mappers for Federation use case |
| 50 | +- Federation `__resolveReference` resolver is available for Interfaces |
| 51 | +- Fixed Federation directives types such as `@external`, `@requires`, etc. |
| 52 | +- Interface non-meta resolvers are no longer generated. |
| 53 | +- `__isTypeOf` resolver is no longer generated for output types which are not Interface implementing |
| 54 | + types or Union member types |
| 55 | +- `UnwrappedObject` type is no longer generated |
| 56 | +- `Record<PropertyKey, never>` is generated instead of `{}` for empty object types |
| 57 | +- Deprecated `generateInternalResolversIfNeeded` option. Codegen decides whether to generate meta |
| 58 | + resolvers to match the spec |
| 59 | +- Deprecated `watchConfig`, `dedupeFragments` and `noGraphQLTag` legacy options |
| 60 | +- Dropped Node 18 support |
| 61 | +- Refactored internal type overrides that has been causing confusion and frustration to |
| 62 | + contributors. This impacts downstream plugins that extend base `typescript` and |
| 63 | + `typescript-resolvers` plugins. |
| 64 | +
|
| 65 | +## Other Changes |
| 66 | +
|
| 67 | +- Partial success writes successful generation to file |
| 68 | +- Migrated from Jest to Vitest |
| 69 | +
|
| 70 | +## Summary |
| 71 | +
|
| 72 | +This major release strengthens type safety for both Federation and standard GraphQL servers, |
| 73 | +simplifies configs, and improves contributor experience. Thanks to community feedback and |
| 74 | +collaboration, GraphQL Code Generator is more reliable and easier to extend than ever. |
| 75 | +
|
| 76 | +If you spot problems or have unsupported use cases, please create issues |
| 77 | +[here](https://github.com/dotansimha/graphql-code-generator/issues) to help us track and continue to |
| 78 | +make improvements! |
0 commit comments