[cli] test: reproduce #6803 — codegen runs twice for codegen then codegen watch (failing) - #10948
Draft
eddeee888 wants to merge 1 commit into
Draft
[cli] test: reproduce #6803 — codegen runs twice for codegen then codegen watch (failing)#10948eddeee888 wants to merge 1 commit into
codegen then codegen watch (failing)#10948eddeee888 wants to merge 1 commit into
Conversation
|
eddeee888
force-pushed
the
claude/sweet-bardeen-oegxya
branch
from
September 12, 2026 12:16
09e3b0a to
56fd82b
Compare
Contributor
…n watch` Watch mode unconditionally runs a full codegen pass before it starts watching for file changes (packages/graphql-codegen-cli/src/utils/watcher.ts, `createWatcher`'s `runningWatcher` promise). There is currently no way to opt out of that initial run. This matters for the reported workflow: run `codegen` once (to fail fast before compiling), then start `codegen watch` to keep types up to date. Watch mode's own initial pass duplicates that just-completed run with nothing having changed in between. Adds a failing test that mirrors this exact workflow: a plain, non-watch `generate()` call (step 1, standing in for the first `codegen` invocation), immediately followed by starting a watcher against the same schema/documents (step 2, standing in for `codegen watch`). It asserts `executeCodegen` was called a total of once after both steps, since nothing changed between them. It fails today because watch mode always runs its own initial pass regardless — `executeCodegen` ends up called twice. eddeee888:oss:issue-verify Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qAsujZbmFpSQmLQYQiq9Z
eddeee888
force-pushed
the
claude/sweet-bardeen-oegxya
branch
from
September 12, 2026 12:26
56fd82b to
29412b5
Compare
codegen then codegen watch (failing)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This is a checkpoint PR, not a fix. It adds a failing test that proves the behavior reported in #6803 exists in the current code — it does not need to merge, or even go green, before a follow-up fix builds on top of it.
Relates to #6803
What #6803 reports: in the common workflow of running
codegenonce (to fail fast before compiling) and thencodegen watchto keep types up to date while developing,codegen watchitself unconditionally runs a full codegen pass again before it starts watching for file changes — duplicating the run that was just done, with nothing having changed in between.Confirmed directly in the source, not just from the issue text —
packages/graphql-codegen-cli/src/utils/watcher.ts,createWatcher():There is no existing option to skip this initial run.
Type of change
issue-verify/issue-fixworkflow below)How Has This Been Tested?
Added a new test,
Watch runs - duplicate initial run (#6803)inpackages/graphql-codegen-cli/tests/watcher.run.spec.ts, that directly mirrors the reported workflow rather than any hypothetical fix API:generate()call against a schema/documents pair, standing in for the firstcodegenCLI invocation.createWatcher), against the same schema/documents with nothing changed on disk, standing in for the immediately-followingcodegen watchinvocation.It spies on
executeCodegenand asserts the total call count across both steps is1(nothing changed, so a second full run is redundant).Run:
pnpm vitest run tests/watcher.run.spec.ts -t "duplicate initial run"insidepackages/graphql-codegen-cli.Captured failure (current behavior — codegen runs a second time regardless):
This test is left failing on purpose — it's the checkpoint this PR exists to produce, not something to skip or mark pending.
Test Environment:
@graphql-codegen/cli: workspace (unreleased)Checklist:
Further comments
This PR is produced by an
issue-verifypass and is meant to be picked up directly by a follow-upissue-fixPR, which will implement an actual mechanism for watch mode to skip its redundant initial codegen run and turn this test green. The test intentionally avoids assuming any particular fix API/config shape — it only asserts on the observable symptom (executeCodegencall count).🤖 Generated with Claude Code
https://claude.ai/code/session_019qAsujZbmFpSQmLQYQiq9Z