CODEGEN-935 - Fix extractAllFieldsToTypes=true with @defer causing duplicated types to be generated#10897
CODEGEN-935 - Fix extractAllFieldsToTypes=true with @defer causing duplicated types to be generated#10897eddeee888 wants to merge 3 commits into
extractAllFieldsToTypes=true with @defer causing duplicated types to be generated#10897Conversation
🦋 Changeset detectedLatest commit: fab112c The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🚀 Snapshot Release (
|
| Package | Version | Info |
|---|---|---|
@graphql-codegen/visitor-plugin-common |
7.2.1-alpha-20260714143946-fab112cc1364eed9ddf4bac70bb5639b89335f24 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/typescript-operations |
6.1.1-alpha-20260714143946-fab112cc1364eed9ddf4bac70bb5639b89335f24 |
npm ↗︎ unpkg ↗︎ |
There was a problem hiding this comment.
Pull request overview
Fixes TypeScript operations type generation when extractAllFieldsToTypes: true interacts with incremental delivery (@defer) and causes duplicate dependent type declarations (TS “Duplicate identifier” errors) in @graphql-codegen/visitor-plugin-common.
Changes:
- Disambiguate extracted dependent type names when multiple selection-set variants are generated for the same field/type by appending an index suffix.
- Add a regression test covering
extractAllFieldsToTypes: truewith a deferred fragment spread (#10867). - Add a changeset to release patch versions for the affected packages.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/plugins/typescript/operations/tests/extract-all-types-with-defer.spec.ts | Adds a regression test asserting unique extracted type names when @defer creates multiple variants. |
| packages/plugins/other/visitor-plugin-common/src/selection-set-to-object.ts | Ensures generated dependent type names are unique when multiple grouped selections exist for the same fieldName/typeName. |
| .changeset/beige-birds-agree.md | Declares patch releases for the two impacted packages. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
💻 Website PreviewThe latest changes are available as preview in: https://pr-10897.graphql-code-generator.pages.dev |
Description
This PR fixes a scenario where
extractAllFieldsToTypes=truewith@deferare used together, it may generate duplicated typesRelated #10867
Type of change