Skip to content

Deduplicate external fragments in typescript-operations#10728

Open
Nurou wants to merge 1 commit intodotansimha:masterfrom
Nurou:nurou/dedupe-external-fragments
Open

Deduplicate external fragments in typescript-operations#10728
Nurou wants to merge 1 commit intodotansimha:masterfrom
Nurou:nurou/dedupe-external-fragments

Conversation

@Nurou
Copy link
Copy Markdown

@Nurou Nurou commented Apr 16, 2026

This deduplicates externalFragments by name in @graphql-codegen/typescript-operations before they are passed to TypeScriptDocumentsVisitor.

Why:

  • near-operation-file can supply repeated nested externalFragments
  • typescript-operations currently forwards them as-is
  • this can cause severe blow-ups when repeated fragment spreads are nested

This is related to dotansimha/graphql-code-generator-community#752.

Validation:

  • added a regression test that asserts repeated externalFragments are deduped before visiting documents
  • yarn workspace @graphql-codegen/typescript-operations vitest run tests/ts-documents.externalFragments.spec.ts tests/ts-documents.externalDocuments.spec.ts

Local benchmark from a downstream repo using near-operation-file + typescript-operations:

  • before: ~248s
  • after dedupe: ~2s

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 16, 2026

⚠️ No Changeset found

Latest commit: b8e2c98

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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