Skip to content

fix(near-operation-file): import root-level polymorphic fragment spreads - #1643

Open
robertmaier wants to merge 1 commit into
dotansimha:mainfrom
robertmaier:fix/near-operation-file-root-fragment-spread-imports
Open

robertmaier wants to merge 1 commit into
dotansimha:mainfrom
robertmaier:fix/near-operation-file-root-fragment-spread-imports

Conversation

@robertmaier

@robertmaier robertmaier commented Oct 6, 2026 •

Copy link
Copy Markdown

analyzeFragmentTypeUsage only visited Field nodes, so a polymorphic
fragment spread directly at the root of a fragment or operation was
never analysed against its type condition. When the same fragment was
also spread in a nested field, only the variants matching that nested
field's type were imported, leaving the generated file referencing
undeclared <Fragment>_<Type>_Fragment names. When it was spread only
at the root, the preset fell back to importing every possible type,
which happened to work.

Also visit FragmentDefinition and OperationDefinition and analyse
their selection sets against the fragment's type condition / the
operation's root type.

refs: None

Fixes #1644

analyzeFragmentTypeUsage only visited Field nodes, so a polymorphic
fragment spread directly at the root of a fragment or operation was
never analysed against its type condition. When the same fragment was
also spread in a nested field, only the variants matching that nested
field's type were imported, leaving the generated file referencing
undeclared `<Fragment>_<Type>_Fragment` names. When it was spread only
at the root, the preset fell back to importing every possible type,
which happened to work.

Also visit FragmentDefinition and OperationDefinition and analyse
their selection sets against the fragment's type condition / the
operation's root type.

refs: None
@changeset-bot

changeset-bot Bot commented Oct 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 026c25a

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

This PR includes changesets to release 1 package
Name Type
@graphql-codegen/near-operation-file-preset 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

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.

[near-operation-file] Missing imports for polymorphic fragments spread at the root of a fragment/operation

1 participant