Repository navigation
Query mutation options in core - #10973
benjavicente wants to merge 3 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Core helper contracts and exports packages/query-core/src/queryOptions.ts, packages/query-core/src/infiniteQueryOptions.ts, packages/query-core/src/mutationOptions.ts, packages/query-core/src/index.ts, .changeset/quiet-cooks-sparkle.md |
Adds three typed helpers that return their supplied options unchanged, exports the helpers and core option types, and records a minor changeset for @tanstack/query-core. |
Core helper runtime and type tests packages/query-core/src/__tests__/options.test.ts, packages/query-core/src/__tests__/queryOptions.test-d.tsx, packages/query-core/src/__tests__/infiniteQueryOptions.test-d.tsx, packages/query-core/src/__tests__/mutationOptions.test-d.tsx |
Tests helper passthrough and behavior. Type tests cover query-key data tags, initial-data variants, skipToken, infinite-page types, mutation keys, and rejection of _defaulted. |
Framework adapter type compatibility packages/{angular-query-experimental,lit-query,preact-query,react-query,solid-query,svelte-query}/... |
Adds type tests passing core query, infinite-query, and mutation options to the corresponding adapter APIs. |
Framework reference documentation docs/framework/{angular,lit,preact,react,solid,svelte}/reference/..., docs/framework/react/guides/query-options.md, docs/config.json |
Adds reference pages and navigation links for the core option types. The React guide describes the core and adapter helpers. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Feature
Suggested labels: package: svelte-query
Suggested reviewers: sukvvon
Merge Risk: 
Minimal · up to 82751
-
The supplied evidence identifies no issue that needs resolution before merging.
Pre-merge checks: 
5
-
Full details: Title check
-
Explanation
The title "Query mutation options in core" names a real part of the changeset: adding the mutationOptions helper to
@tanstack/query-core. However, the change also adds queryOptions and infiniteQueryOptions, and the title mentions only mutation options. That makes the title partially related: it covers a real aspect of the change but not the main point, which is the addition of all three framework-agnostic options helpers to core. The title is short, specific, and free of noise.
Full details: Description check
-
Explanation
The description follows the repository template. It has the Changes section, which explains the motivation and cites the linked discussions. It has the Checklist, with the contributing guide, local test, and AI policy items. It has the Release Impact section, with the changeset item checked. The AI policy checkbox is missing from the author's checklist, and the Changes section does not say how the helpers are used. The description also contains struck-through notes and open questions that the author has not resolved. These gaps are minor, so the description is mostly complete.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
| export { queryOptions } from './queryOptions' | ||
| export type { CoreQueryOptions } from './queryOptions' | ||
| export { mutationOptions } from './mutationOptions' | ||
| export type { CoreMutationOptions } from './mutationOptions' |
There was a problem hiding this comment.
since adapters re-export the core and then export their own things, they won’t have access to the queryOptions from the core, right? is that on purpose?
There was a problem hiding this comment.
Yes. I don't think someone wanting to define shared query options for multiple frameworks would import from a framework specific package.
| const { data } = useQuery(options) | ||
| expectTypeOf(data).toEqualTypeOf< | ||
| { id: string; title: string } | undefined | ||
| >() |
There was a problem hiding this comment.
with this, what’s the difference between useQuery(queryOptions) and useQuery(coreQueryOption) ?
in other words, if they are compatible, why would e.g. the react adapter need a separate queryOptions and not just re-export and let users use the one from the core?
There was a problem hiding this comment.
queryOptions from each library could extend the coreQueryOption, like with deferStream in Solid or RefOrGetter pattern in Vue.
|
I avoided changing the types of the adapters to reuse the new types in core to keep the changes of this PR small (only test changes for most adapters). The code query options could be something that adapters completely reuse. |
I guess you mean re-use on type-level, because at runtime, they all don’t do anything? |
Yes |
|
okay, let’s do it 🔥 . can you fix the conflicts ? |
ff39c7b to
51a48d8
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
51a48d8 to
fc5ffde
Compare
🦋 Changeset detectedLatest commit: 8275110 The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 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 |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx affected --targets=test:sherif,test:knip,tes... |
❌ Failed | 6m | View ↗ |
nx run-many --target=build --exclude=examples/*... |
✅ Succeeded | 36s | View ↗ |
☁️ Nx Cloud last updated this comment at 2026-10-28 22:52:53 UTC
a05d8c3 to
9d64034
Compare
|
Did a rebase on latest main and found a couple of issues with Vue that would make the PR too big, so I removed the Vue changes to support it 😞 Vue has a different main options shape for supporting reactive refs, and the enabled callback doesn't have the query parameter This would remain compatible with query core ( |
9d64034 to
27885d1
Compare
27885d1 to
8275110
Compare

🎯 Changes
Adds
queryOptions,infiniteQueryOptionsandmutationOptionsto the core library.This was requested at #10735 and #9258 discussions. Having those function in core is useful for defining shared query options for a framework agnostic layer, or for server side usage. Specially for using query keys for type-safe interactions with the core imperative API.
Most of the frameworks accept the shared interface from core without changes, with Vue been the exception
that require a small change in the interface sinceMaybeRefOrGetterwasn't compatible. I added runtime test for Vue to demonstrate that it works with the core query options, with the same shape of() => coreOptionsas Solid/Angular/Lit/Svelte.About docs: There is a lot of outdated docs, so I excluded the doc generation in the PR. I didn't add docs mentioning that core has this new functions.Pending questions:
CoreQueryOptionsandCoreMutationOptionsok names for the interface the newqueryOptionsandmutationOptionsrequires? The core library already hasQueryOptionsandMutationOptions. The newCoreQueryOptionsandCoreMutationOptionsare the equivalent ofQueryOptionsandMutationOptionsexported by each individual adapter. The new types can't replace the base options alredy defined in core.CoreQueryOptionsandCoreMutationOptionsbe excluded from the re-export from core? How? Each adapter exportsqueryOptionsandmutationOptions, so a consumer can't import the implementation defined in core if the consumer hasn't installed@tanstack/query-coredirectly, but they can consumeCoreQueryOptionsandCoreMutationOptions.I'm not happy on how theuseQueryinterface of Vue had to be extended, there is probably something that can be done there to simplify the types.✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
New Features
queryOptions,infiniteQueryOptions, andmutationOptionshelpers, along with shared types for describing their options.Documentation