Skip to content

CODEGEN-935 - Fix extractAllFieldsToTypes=true with @defer causing duplicated types to be generated#10897

Open
eddeee888 wants to merge 3 commits into
masterfrom
codegen-935-extractAllFieldsToTypes-with-defer
Open

CODEGEN-935 - Fix extractAllFieldsToTypes=true with @defer causing duplicated types to be generated#10897
eddeee888 wants to merge 3 commits into
masterfrom
codegen-935-extractAllFieldsToTypes-with-defer

Conversation

@eddeee888

Copy link
Copy Markdown
Collaborator

Description

This PR fixes a scenario where extractAllFieldsToTypes=true with @defer are used together, it may generate duplicated types

Related #10867

Type of change

  • Bug fix (non-breaking change which fixes an issue)

@changeset-bot

changeset-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fab112c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@graphql-codegen/visitor-plugin-common Patch
@graphql-codegen/typescript-operations Patch

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

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

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 ↗︎

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: true with 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.

@github-actions

Copy link
Copy Markdown
Contributor

💻 Website Preview

The latest changes are available as preview in: https://pr-10897.graphql-code-generator.pages.dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants