Skip to content

[typescript-operations] test: reproduce nested fragment import dropped with omitOperationSuffix + combine (failing) (#11026) - #11027

Closed
eddeee888 wants to merge 1 commit into
masterfrom
claude/graphql-codegen-issue-11026-qkanu7
Closed

eddeee888 wants to merge 1 commit into
masterfrom
claude/graphql-codegen-issue-11026-qkanu7

Conversation

@eddeee888

Copy link
Copy Markdown
Collaborator

Description

This is a checkpoint PR. It adds a failing test showing that the bug in #11026 is real. It doesn't fix anything yet. The fix will be built on top of this commit.

Related #11026

When omitOperationSuffix: true and inlineFragmentTypes: 'combine' are both set, the near-operation-file preset leaves out the import for a fragment that is spread inside another fragment. The test mirrors the reporter's repro:

  • markdown.ts has one gql tag: fragment MarkdownFragment.
  • op.ts has two gql tags: fragment WidgetFragment { title { ...MarkdownFragment } } and query Ping { ping { ...WidgetFragment } }.

The test runs the real preset through executeCodegen against this package's own src.

Current failure:

FAIL  tests/ts-documents.near-operation-file.spec.ts > Issue #11026 - imports fragment used by another fragment in the same file when omitOperationSuffix=true
AssertionError: expected '...' to match /import (type )?\{ MarkdownFragment \} from '\.\/markdown\.generated';/

The generated op.generated.ts contains export type WidgetFragment = { title: MarkdownFragment | null }; but no import for MarkdownFragment. There's also a control test with omitOperationSuffix: false. It passes and emits import { MarkdownFragmentFragment } from './markdown.generated';.

Likely root cause (not confirmed yet): with omitOperationSuffix, a fragment named MarkdownFragment gives the same identifier name to its document import and its type import. The preset merges fragment imports from the same file by name only. The Ping source's document entry overwrites the WidgetFragment source's type entry. typescript-operations' getImports() then keeps only kind === 'type' entries, so no import is emitted.

Type of change

  • Bug fix (non-breaking change which fixes an issue): failing test only, no fix yet

How Has This Been Tested?

  • npx vitest --no-watch --project typescript-operations packages/plugins/typescript/operations/tests/ts-documents.near-operation-file.spec.ts gives 1 failed (expected) and 1 passed (the control).

This adds @graphql-codegen/near-operation-file-preset@5.2.2 (the version from the issue) as a devDependency of typescript-operations. The lockfile was updated and deduped with pnpm dedupe.

Further comments

Red CI on this PR is expected: the failing test is the checkpoint.

🤖 Generated with Claude Code

https://claude.ai/code/session_019G21LchfGxeMbf2U5bR6cL


Generated by Claude Code

…ationSuffix + combine

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019G21LchfGxeMbf2U5bR6cL

eddeee888:oss:issue-verify
@changeset-bot

changeset-bot Bot commented Oct 2, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 90183be

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

@github-actions

github-actions Bot commented Oct 2, 2026

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/time 7.1.1-alpha-20261002102719-90183bed6cbcef428f429066eb879f0bca89f831 npm ↗︎ unpkg ↗︎
@graphql-codegen/visitor-plugin-common 7.2.8-alpha-20261002102719-90183bed6cbcef428f429066eb879f0bca89f831 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-operations 6.1.10-alpha-20261002102719-90183bed6cbcef428f429066eb879f0bca89f831 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript 6.1.1-alpha-20261002102719-90183bed6cbcef428f429066eb879f0bca89f831 npm ↗︎ unpkg ↗︎
@graphql-codegen/client-preset 6.2.1-alpha-20261002102719-90183bed6cbcef428f429066eb879f0bca89f831 npm ↗︎ unpkg ↗︎
@graphql-codegen/plugin-helpers 7.4.1-alpha-20261002102719-90183bed6cbcef428f429066eb879f0bca89f831 npm ↗︎ unpkg ↗︎

@eddeee888 eddeee888 closed this Oct 10, 2026
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