feat(tanstack-query): prefix option to avoid key conflicts#1692
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
More templates
@orpc/arktype
@orpc/bun
@orpc/client
@orpc/cloudflare
@orpc/contract
@orpc/experimental-effect
@orpc/evlog
@orpc/json-schema
@orpc/nest
@orpc/next
@orpc/openapi
@orpc/opentelemetry
@orpc/pinia-colada
@orpc/pino
@orpc/publisher
@orpc/ratelimit
@orpc/server
@orpc/shared
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/zod
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the replacement of path with prefix in @orpc/tanstack-query, aligning key generation with @orpc/pinia-colada.
RouterUtilsOptions.pathis replaced byprefix?: stringviaOperationKeyPrefixOptions.generateOperationKeynow prepends the prefix as a separate tuple element.ProcedureUtilsOptionscarries the prefix and every key method passes it through.createRouterUtilsgains an optional positionalpathparameter used internally by contract utils to keep proceduremeta.pathrooting.- Tests and docs are updated;
vitestandtscpass for@orpc/tanstack-query.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Caution
The latest commit hides the internal base-path parameter from the public createRouterUtils signature, but two call sites still rely on passing it. This produces a TypeScript error and a failing test, and at runtime contract utils would be rooted at the wrong path.
Reviewed changes — since the prior review, the public createRouterUtils signature was trimmed to hide the internal base-path parameter, and key-related types were relocated from types.ts to key.ts.
- Hid the base-path parameter from
createRouterUtilsby moving routing recursion through an internalcreateRouterUtilsInternalhelper. - Moved
OperationKey*types fromtypes.tsintokey.tsand updated imports acrossprocedure-utils.ts,router-utils.ts, andcontract-utils.ts. - Updated tests and docs to reflect the new
prefix-only public API.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Caution
The latest commit removes the public base-path tests, but the underlying TS2554 type error and runtime path bug it exposed are still present.
Reviewed changes — latest commit removed the now-invalid public base-path test and the @ts-expect-error case for the removed path option.
- Removed the
roots utils at the given base pathunit test and thepath: ['base']type-test case.
🚨 Contract utils still pass a base path that createRouterUtils no longer accepts
Removing the failing tests is correct for the public API, but packages/tanstack-query/src/contract-utils.ts still passes the procedure's meta.path as the third argument to createRouterUtils. That exported signature only accepts (client, options), so pnpm --filter @orpc/tanstack-query type:check still reports src/contract-utils.ts(63,8): error TS2554: Expected 1-2 arguments, but got 3.
At runtime the extra argument is ignored, so contract utils are rooted at [] instead of the procedure path. This still needs an internal helper that can carry the base path without exposing it publicly.
Technical details
# Contract utils still pass a base path that `createRouterUtils` no longer accepts
## Affected sites
- `packages/tanstack-query/src/contract-utils.ts:60-63` — passes `path` as the third argument; produces the typecheck error and a runtime root mismatch.
## Required outcome
- `contract-utils.ts` (and any other internal caller) must be able to supply a base path to the router-utils recursion without making it part of the public `createRouterUtils` signature.
## Suggested approach
- Export a package-private helper from `router-utils.ts` (for example, `createRouterUtilsWithPath`) that accepts the base path and delegates to `createRouterUtilsInternal`, or have `contract-utils.ts` import and call `createRouterUtilsInternal` directly.
- Keep the public `createRouterUtils` signature as `(client, options)`.
## Open questions for the human
- None — the fix is mechanical.Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the latest commit resolves the contract-utils base-path routing issue flagged in the prior review by passing the procedure's meta.path inside the RouterUtilsOptions object and merging it with any existing base path.
createContractUtilsFactorynow combinesoptions.pathwith the procedure'smeta.pathand passes the merged path tocreateRouterUtils, so contract utils are rooted at the correct base path.- The contract-utils unit tests were updated to include a base
pathand assert the merged path flows intocreateRouterUtils. createRouterUtilsretains the base path as an@internaloption while keeping its public signature as(client, options).
pnpm vitest run packages/tanstack-query/src/ and pnpm --filter @orpc/tanstack-query type:check pass.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
prefix option to avoid key conflicts

Summary
Prefer
prefixoverpathto avoiding conflict keys in@orpc/tanstack-query