Skip to content

refactor(plugin-react-query): use the new core match predicate instead of the dispatcher - #730

Merged
stijnvanhulle merged 3 commits into
mainfrom
claude/react-query-match-dispatch
Jul 18, 2026
Merged

refactor(plugin-react-query): use the new core match predicate instead of the dispatcher#730
stijnvanhulle merged 3 commits into
mainfrom
claude/react-query-match-dispatch

Conversation

@stijnvanhulle

@stijnvanhulle stijnvanhulle commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

🎯 Changes

#728 fixed kubb-labs/kubb#3816 (five hook generators running per operation, four returning early) with a hand-rolled createOperationDispatcher: classify the operation once, then manually instantiate a renderer and call ctx.upsertFile() for each matching generator, bypassing the normal Generator → driver → renderer pipeline.

kubb-labs/kubb#3828 added a match predicate to Generator in @kubb/core, released in kubb@5.0.0-beta.104, so the driver itself can skip a non-matching generator before calling it. This PR uses that instead: each of the five generators (query, suspenseQuery, infiniteQuery, suspenseInfiniteQuery, mutation) gets a match that holds exactly the condition it used to check at the top of operation() (classification, plus suspense/infinite/hooks/queryParam gating where relevant), and plugin.ts goes back to registering the five generators directly, no dispatcher.

The kubb catalog version in pnpm-workspace.yaml is bumped to 5.0.0-beta.104. Generated output is unchanged, verified against tests/3.0.x/pluginReactQuery.test.ts's 11-config snapshot suite run against the real published package.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is for the docs (no release).

Generated by Claude Code

…d of the dispatcher

Give each of the five hook generators a match predicate instead of
classifying and bailing out inside operation(). This is what
createOperationDispatcher (added in #728 to fix kubb-labs/kubb#3816)
was working around: @kubb/core's Generator now supports match natively,
so the core driver skips a non-matching generator before calling it and
plugin.ts goes back to registering the five generators directly.

Generated output is unchanged (verified against
tests/3.0.x/pluginReactQuery.test.ts's 11-config snapshot suite, run
locally against a kubb build linked from ../kubb via pnpm-workspace.yaml's
commented-out overrides).

Requires kubb-labs/kubb#3828 to merge and release before this is
mergeable: without match support in the driver, these generators would
run unconditionally for every operation, since the old classify-and-bail
guards were moved into match. Do not merge until the kubb catalog
version here is bumped past that release.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LnAWjXX2zoWWScgn7NsLaf
@codesandbox

codesandbox Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@changeset-bot

changeset-bot Bot commented Jul 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7a8a7dc

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

This PR includes changesets to release 3 packages
Name Type
@kubb/plugin-react-query Patch
tests-3.0.x Patch
e2e 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

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LnAWjXX2zoWWScgn7NsLaf
@pkg-pr-new

pkg-pr-new Bot commented Jul 18, 2026

Copy link
Copy Markdown
More templates

@kubb/plugin-axios

npm i https://pkg.pr.new/@kubb/plugin-axios@730

@kubb/plugin-cypress

npm i https://pkg.pr.new/@kubb/plugin-cypress@730

@kubb/plugin-faker

npm i https://pkg.pr.new/@kubb/plugin-faker@730

@kubb/plugin-fetch

npm i https://pkg.pr.new/@kubb/plugin-fetch@730

@kubb/plugin-mcp

npm i https://pkg.pr.new/@kubb/plugin-mcp@730

@kubb/plugin-msw

npm i https://pkg.pr.new/@kubb/plugin-msw@730

@kubb/plugin-react-query

npm i https://pkg.pr.new/@kubb/plugin-react-query@730

@kubb/plugin-redoc

npm i https://pkg.pr.new/@kubb/plugin-redoc@730

@kubb/plugin-swr

npm i https://pkg.pr.new/@kubb/plugin-swr@730

@kubb/plugin-ts

npm i https://pkg.pr.new/@kubb/plugin-ts@730

@kubb/plugin-vue-query

npm i https://pkg.pr.new/@kubb/plugin-vue-query@730

@kubb/plugin-zod

npm i https://pkg.pr.new/@kubb/plugin-zod@730

commit: 7a8a7dc

@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Size Change: +183 B (+0.06%)

Total Size: 298 kB

📦 View Changed
Filename Size Change
packages/plugin-react-query/dist/index.cjs 17.2 kB +91 B (+0.53%)
packages/plugin-react-query/dist/index.js 16.7 kB +92 B (+0.55%)
ℹ️ View Unchanged
Filename Size
packages/plugin-axios/dist/index.cjs 14.4 kB
packages/plugin-axios/dist/index.js 13.9 kB
packages/plugin-axios/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-cypress/dist/index.cjs 5.24 kB
packages/plugin-cypress/dist/index.js 5.17 kB
packages/plugin-cypress/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-faker/dist/index.cjs 13.8 kB
packages/plugin-faker/dist/index.js 13.7 kB
packages/plugin-faker/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-fetch/dist/index.cjs 14.4 kB
packages/plugin-fetch/dist/index.js 13.9 kB
packages/plugin-fetch/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-mcp/dist/index.cjs 9.63 kB
packages/plugin-mcp/dist/index.js 9.14 kB
packages/plugin-mcp/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-msw/dist/index.cjs 5.33 kB
packages/plugin-msw/dist/index.js 5.24 kB
packages/plugin-msw/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-react-query/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-redoc/dist/index.cjs 2.21 kB
packages/plugin-redoc/dist/index.js 1.75 kB
packages/plugin-redoc/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-swr/dist/index.cjs 11.5 kB
packages/plugin-swr/dist/index.js 11 kB
packages/plugin-swr/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-ts/dist/index.cjs 23.6 kB
packages/plugin-ts/dist/index.js 22.9 kB
packages/plugin-ts/dist/rolldown-runtime-CNktS9qV.js 291 B
packages/plugin-vue-query/dist/index.cjs 14.3 kB
packages/plugin-vue-query/dist/index.js 13.8 kB
packages/plugin-vue-query/dist/rolldown-runtime-C0LytTxp.js 168 B
packages/plugin-zod/dist/index.cjs 18.5 kB
packages/plugin-zod/dist/index.js 18.3 kB
packages/plugin-zod/dist/rolldown-runtime-C0LytTxp.js 168 B

compressed-size-action

The published beta.104 carries the match predicate support this branch
depends on. Simplify each generator's match to narrow SchemaNode |
OperationNode via a single cast plus isHttpOperationNode instead of a
node.kind string check, and drop the queryParam regex normalization in
favor of a plain includes() check against both the plain and optional key.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LnAWjXX2zoWWScgn7NsLaf
@stijnvanhulle
stijnvanhulle marked this pull request as ready for review July 18, 2026 14:02
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jul 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📊 Dependency Size Changes

📦 Package 📏 Size
@kubb/core@5.0.0-beta.103 → @kubb/core@5.0.0-beta.104 21.2 kB
@kubb/ast@5.0.0-beta.103 → @kubb/ast@5.0.0-beta.104 10.9 kB
@kubb/plugin-barrel@5.0.0-beta.103 → @kubb/plugin-barrel@5.0.0-beta.104 8.9 kB
@kubb/adapter-oas@5.0.0-beta.103 → @kubb/adapter-oas@5.0.0-beta.104 3.1 kB
@kubb/kit@5.0.0-beta.103 → @kubb/kit@5.0.0-beta.104 27 B
@kubb/parser-ts@5.0.0-beta.103 → @kubb/parser-ts@5.0.0-beta.104 0 B
kubb@5.0.0-beta.103 → kubb@5.0.0-beta.104 0 B
@kubb/cli@5.0.0-beta.103 → @kubb/cli@5.0.0-beta.104 0 B
@kubb/mcp@5.0.0-beta.103 → @kubb/mcp@5.0.0-beta.104 0 B
@kubb/renderer-jsx@5.0.0-beta.103 → @kubb/renderer-jsx@5.0.0-beta.104 0 B
@kubb/parser-md@5.0.0-beta.103 → @kubb/parser-md@5.0.0-beta.104 0 B
unplugin-kubb@5.0.0-beta.103 → unplugin-kubb@5.0.0-beta.104 0 B

Total size change: 44 kB

@stijnvanhulle
stijnvanhulle merged commit 350bcca into main Jul 18, 2026
16 checks passed
@stijnvanhulle
stijnvanhulle deleted the claude/react-query-match-dispatch branch July 18, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

react-query runs five operation generators for every operation

2 participants