refactor(plugin-react-query): use the new core match predicate instead of the dispatcher - #730
Merged
Merged
Conversation
…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
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
🦋 Changeset detectedLatest commit: 7a8a7dc The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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
More templates
@kubb/plugin-axios
@kubb/plugin-cypress
@kubb/plugin-faker
@kubb/plugin-fetch
@kubb/plugin-mcp
@kubb/plugin-msw
@kubb/plugin-react-query
@kubb/plugin-redoc
@kubb/plugin-swr
@kubb/plugin-ts
@kubb/plugin-vue-query
@kubb/plugin-zod
commit: |
Contributor
|
Size Change: +183 B (+0.06%) Total Size: 298 kB 📦 View Changed
ℹ️ View Unchanged
|
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
marked this pull request as ready for review
July 18, 2026 14:02
Contributor
📊 Dependency Size Changes
Total size change: 44 kB |
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.
🎯 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 callctx.upsertFile()for each matching generator, bypassing the normalGenerator→ driver → renderer pipeline.kubb-labs/kubb#3828 added a
matchpredicate toGeneratorin@kubb/core, released inkubb@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 amatchthat holds exactly the condition it used to check at the top ofoperation()(classification, plussuspense/infinite/hooks/queryParamgating where relevant), andplugin.tsgoes back to registering the five generators directly, no dispatcher.The
kubbcatalog version inpnpm-workspace.yamlis bumped to5.0.0-beta.104. Generated output is unchanged, verified againsttests/3.0.x/pluginReactQuery.test.ts's 11-config snapshot suite run against the real published package.✅ Checklist
pnpm run test.🚀 Release Impact
Generated by Claude Code