You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make clear in mutation doc that using other ways of writing to backend is ok (#750)
* docs: Add callout about bypassing mutation system
Users can completely bypass the TanStack DB mutation system and use
their existing mutation logic by calling backend APIs directly and
either waiting for sync or manually refetching collections.
* docs: Improve bypass mutations callout
- Clarify this is about not rewriting existing logic, not avoiding optimistic updates
- Add Electric's awaitTxId as a sync option
- Show collection-specific approaches (QueryCollection refetch vs Electric awaitTxId)
- Provide examples for both patterns
* docs: Move bypass mutations to Mutation Approaches section
Present bypassing the mutation system as one of several valid approaches
rather than an aggressive callout. Fits more naturally as the first
option under Mutation Approaches.
* docs: Move bypass mutations to last approach
Present TanStack DB's mutation approaches first, with bypassing
the mutation system as the final option for those who prefer
their existing patterns.
* docs: Remove createTransaction from Mutation Approaches
Manual transactions is niche and covered in detail later in its own
section. Keep Mutation Approaches focused on the main patterns.
* docs: Clarify why to await sync in bypass approach
Explain that awaiting refetch/sync lets you know when the server
change is loaded in the collection, so you can render new data,
hide loading indicators, navigate, etc.
* docs: Add success messages to sync completion reasons
Include showing success messages as a common reason to await
sync completion, alongside rendering data, hiding loaders, and navigating.
* docs: Explain write-then-sync pattern in bypass approach
Clarify that you write to the server like normal, then use your
collection's mechanism to await the server write and know when
to update UI.
---------
Co-authored-by: Claude <[email protected]>
-**Bypass the mutation system**: Use your existing mutation logic without rewriting
201
+
202
+
### Bypass the Mutation System
203
+
204
+
If you already have mutation logic in an existing system and don't want to rewrite it, you can **completely bypass** TanStack DB's mutation system and use your existing patterns.
205
+
206
+
With this approach, you write to the server like normal using your existing logic, then use your collection's mechanism for refetching or syncing data to await the server write. After the sync completes, the collection will have the updated server data and you can render the new state, hide loading indicators, show success messages, navigate to a new page, etc.
207
+
208
+
```tsx
209
+
// Call your backend directly with your existing logic
0 commit comments