From df31aa2b0a826817feb1033cadfde6b4e5215853 Mon Sep 17 00:00:00 2001 From: clover caruso Date: Fri, 15 May 2026 13:01:26 -0700 Subject: [PATCH] chore: document that optimistic query helpers trigger refetches resolves #17 --- readme.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index a7fd56e5a5ed368d57745c4977579763e21da200..0abb4aca616540990fe6954c0ee1fa42964fd059 100644 --- a/readme.md +++ b/readme.md @@ -87,6 +87,7 @@ const mutDeleteItem = mutations.define({ // `optimistic` is provided a `helpers` object which implement automatic rollbacks. optimistic({ client, get, helpers, args: [id], onSuccess, onRestore, onRefetch }) { // Remove the items matching the filter, but restore and refetch them on failure. + // On success, the default behavior is to also re-fetch queries. helpers.arrayRemove(queryItemList, (item) => item === id); // Set a property on an object, also restores and refetches. The `obj` // helpers implement a type-safe object path system for nested fields. @@ -115,8 +116,8 @@ const mutDeleteItem = mutations.define({ // Example: `Successfully {description}` describeResult: ({ get, args: [id] }) => "Deleted Item", - // Since the optimistic handler is perfect, there is no need to refetch any - // data once a success case is hit. This defaults to false for simplicity. + // Since this optimistic handler above is perfect, we can decide to disable + // success-based refetching. This is default so that more things just work. refetchOnSuccess: false, }); -- 2.54.0