feat(tanstack-query): define base options and interceptors via contract meta#1705
feat(tanstack-query): define base options and interceptors via contract meta#1705dinwwwh wants to merge 12 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
More templates
@orpc/ai-sdk
@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❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
ℹ️ No critical issues — one minor API-surface note inline.
Reviewed changes — added tanstackQueryMeta, getTanstackQueryMeta, and ContractMetaPlugin so base TanStack Query options and interceptors can be defined on a procedure contract and applied automatically as the default layer under utils options.
packages/tanstack-query/src/meta.ts— introduces thetanstackQueryMetacontract meta plugin,getTanstackQueryMetareader, andContractMetaPluginrouter utils plugin.packages/tanstack-query/src/procedure-utils.ts— addsmergeProcedureUtilsOptions/mergeProcedureUtilsModifierso option modifiers spread-merge and interceptors concatenate across layers.packages/tanstack-query/src/router-utils.ts— switches global/scoped per-procedure option merging tomergeProcedureUtilsOptionsto keep semantics consistent.packages/tanstack-query/src/index.ts— exports the new./metamodule and now also exports./plugin.- Tests and docs — adds
meta.test.ts/meta.test-d.ts, updates therouter-utils.test.tsmock, and documents the contract meta plugin.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
|
Heads-up: the inline suggestion in my review on The actual feedback is just a nit:
|
…ptionsUtilsPlugin
…ery-meta-plugin-edfe5e # Conflicts: # packages/tanstack-query/src/procedure-utils.ts # packages/tanstack-query/src/router-utils.test.ts # packages/tanstack-query/src/router-utils.ts
There was a problem hiding this comment.
ℹ️ One minor suggestion inline.
Reviewed changes — adds tanstackQuery for defining base TanStack Query options/interceptors on procedure contracts, and ContractOptionsUtilsPlugin for applying them automatically via the plugin system. Also refactors router-utils.ts to use a shared mergeProcedureUtilsOptions helper with consistent spread-merge composition semantics.
- Add
tanstackQuerycontract meta plugin — storesProcedureUtilsOptionsunder~tanstack-queryin procedure meta, supports multi-layer merging with interceptor concatenation and modifier composition. - Add
ContractOptionsUtilsPlugin— walks the contract by path viagetRouterContractand merges stored meta as the base layer under scoped/global utils options. - Refactor interceptor merging — extract
mergeProcedureUtilsOptionsandmergeProcedureUtilsModifierinprocedure-utils.ts, use them in bothtanstackQueryaccumulation androuter-utils.tsscoped-options merge. - Export
RouterUtilsPlugininterface —./pluginmodule is now part of the public API, enabling custom plugin implementations. - Tests and type tests — unit tests for storage, merging, function composition, router propagation, and end-to-end
createRouterUtilsflow. Type tests verify contract type inference.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| export * from './contract-utils' | ||
| export * from './key' | ||
| export * from './meta' | ||
| export * from './plugin' |
There was a problem hiding this comment.
ℹ️ export * from './plugin' now makes CompositeRouterUtilsPlugin part of the public API. It's an internal composition primitive that users shouldn't need to construct directly — they pass plain plugin arrays to createTanstackQueryUtils. Consider exporting only RouterUtilsPlugin explicitly or marking CompositeRouterUtilsPlugin with @internal in its JSDoc.
Summary
Define base TanStack Query options and interceptors directly on a procedure contract via
tanstackQuery, and apply them automatically with the newContractOptionsUtilsPlugin.tanstackQueryinfers input, output, and error types from the contract, supports all procedure utils options (keys, options, interceptors), and merges when applied multiple timesContractOptionsUtilsPluginapplies meta options as the base layer: utils level options override them and utils interceptors run after meta interceptorsgetTanstackQueryMetareads the stored options for custom integrations