feat(svelte-query): add 'mutationOptions'#10175
feat(svelte-query): add 'mutationOptions'#10175sukvvon wants to merge 6 commits intoTanStack:mainfrom
Conversation
…nction for type-safe mutation configuration
🦋 Changeset detectedLatest commit: 5048011 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 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a new exported function Changes
Sequence Diagram(s)sequenceDiagram
participant Component
participant MutationOptions as mutationOptions
participant CreateMutation as createMutation
participant QueryClient
participant IsMutating as isMutating
Component->>MutationOptions: provide CreateMutationOptions
Note over MutationOptions: Enforce/reflect types (with/without mutationKey)
MutationOptions-->>Component: return typed options
Component->>CreateMutation: create mutation using options
CreateMutation->>QueryClient: register mutation (cache)
Component->>QueryClient: call mutate()
QueryClient->>QueryClient: track active mutation(s)
Component->>IsMutating: request count/state (optional filter)
IsMutating-->>Component: return count/state
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
|
View your CI Pipeline Execution ↗ for commit 5048011
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/framework/svelte/reference/functions/mutationOptions.md`:
- Around line 8-48: The doc has duplicated "Call Signature" headings for the
overloads of the mutationOptions function causing MD024; update the two headings
so they are distinct (e.g., "Call Signature — Required mutationKey overload" and
"Call Signature — Omitted mutationKey overload" or similar) to describe each
overload clearly; locate the two headings around the mutationOptions function
declaration and CreateMutationOptions/mutationKey references and rename them to
avoid duplicate top-level headings while keeping the linked type references
intact.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
.changeset/smart-spiders-sing.mddocs/config.jsondocs/framework/svelte/reference/functions/mutationOptions.mdpackages/svelte-query/src/index.tspackages/svelte-query/src/mutationOptions.tspackages/svelte-query/tests/mutationOptions/BaseExample.sveltepackages/svelte-query/tests/mutationOptions/mutationOptions.svelte.test.tspackages/svelte-query/tests/mutationOptions/mutationOptions.test-d.ts
| ## Call Signature | ||
|
|
||
| ```ts | ||
| function mutationOptions<TData, TError, TVariables, TOnMutateResult>(options): WithRequired<CreateMutationOptions<TData, TError, TVariables, TOnMutateResult>, 'mutationKey'> | ||
| ``` | ||
|
|
||
| Defined in: [packages/svelte-query/src/mutationOptions.ts](https://github.com/TanStack/query/blob/main/packages/svelte-query/src/mutationOptions.ts) | ||
|
|
||
| ### Type Parameters | ||
|
|
||
| #### TData | ||
|
|
||
| `TData` = `unknown` | ||
|
|
||
| #### TError | ||
|
|
||
| `TError` = `Error` | ||
|
|
||
| #### TVariables | ||
|
|
||
| `TVariables` = `void` | ||
|
|
||
| #### TOnMutateResult | ||
|
|
||
| `TOnMutateResult` = `unknown` | ||
|
|
||
| ### Parameters | ||
|
|
||
| #### options | ||
|
|
||
| `WithRequired`\<[`CreateMutationOptions`](../type-aliases/CreateMutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `'mutationKey'`\> | ||
|
|
||
| ### Returns | ||
|
|
||
| `WithRequired`\<[`CreateMutationOptions`](../type-aliases/CreateMutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `'mutationKey'`\> | ||
|
|
||
| ## Call Signature | ||
|
|
||
| ```ts | ||
| function mutationOptions<TData, TError, TVariables, TOnMutateResult>(options): Omit<CreateMutationOptions<TData, TError, TVariables, TOnMutateResult>, 'mutationKey'> | ||
| ``` |
There was a problem hiding this comment.
Resolve duplicate "Call Signature" headings (MD024 warning).
Rename the headings to distinguish the overloads and avoid markdownlint warnings.
📝 Suggested heading tweak
-## Call Signature
+## Call Signature (with mutationKey)
@@
-## Call Signature
+## Call Signature (without mutationKey)🧰 Tools
🪛 LanguageTool
[grammar] ~18-~18: Ensure spelling is correct
Context: ...nOptions.ts) ### Type Parameters #### TData TData = unknown #### TError TError = `E...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
[grammar] ~26-~26: Ensure spelling is correct
Context: ... #### TError TError = Error #### TVariables TVariables = void #### TOnMutateResult `TOnMut...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
[grammar] ~30-~30: Ensure spelling is correct
Context: ...TVariables TVariables = void #### TOnMutateResult TOnMutateResult = unknown ### Parameters #### optio...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🪛 markdownlint-cli2 (0.21.0)
[warning] 44-44: Multiple headings with the same content
(MD024, no-duplicate-heading)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@docs/framework/svelte/reference/functions/mutationOptions.md` around lines 8
- 48, The doc has duplicated "Call Signature" headings for the overloads of the
mutationOptions function causing MD024; update the two headings so they are
distinct (e.g., "Call Signature — Required mutationKey overload" and "Call
Signature — Omitted mutationKey overload" or similar) to describe each overload
clearly; locate the two headings around the mutationOptions function declaration
and CreateMutationOptions/mutationKey references and rename them to avoid
duplicate top-level headings while keeping the linked type references intact.
…BaseExample and wrap test values with arrow functions
🎯 Changes
Add
mutationOptionsidentity function to@tanstack/svelte-queryfor type-safe mutation configuration, matching the existing implementation inreact-queryandpreact-query.mutationOptionswith two overloads (with/withoutmutationKey)✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
New Features
Documentation
Tests
Chores