authorgravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-05-15 13:01:26-07:00
committergravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-07-22 12:53:46-07:00
logdf31aa2b0a826817feb1033cadfde6b4e5215853
treebabca5942fc8199d8737877aa31d5dd0c8bb77e0
parent0fdd85629ed3b7596c086d169f500b101e77e581
signaturebadge-check Signed by SSH key SHA256:cOKiuRFOeSRxne6EWgHtdQQSlBxjOXm2hOCFnCdLQbQ

chore: document that optimistic query helpers trigger refetches

resolves #17

1 files changed, 3 insertions(+), 2 deletions(-)

readme.md+3-2
...@@ -87,6 +87,7 @@ const mutDeleteItem = mutations.define({...@@ -87,6 +87,7 @@ const mutDeleteItem = mutations.define({
87 // `optimistic` is provided a `helpers` object which implement automatic rollbacks.87 // `optimistic` is provided a `helpers` object which implement automatic rollbacks.
88 optimistic({ client, get, helpers, args: [id], onSuccess, onRestore, onRefetch }) {88 optimistic({ client, get, helpers, args: [id], onSuccess, onRestore, onRefetch }) {
89 // Remove the items matching the filter, but restore and refetch them on failure.89 // Remove the items matching the filter, but restore and refetch them on failure.
90 // On success, the default behavior is to also re-fetch queries.
90 helpers.arrayRemove(queryItemList, (item) => item === id);91 helpers.arrayRemove(queryItemList, (item) => item === id);
91 // Set a property on an object, also restores and refetches. The `obj`92 // Set a property on an object, also restores and refetches. The `obj`
92 // helpers implement a type-safe object path system for nested fields.93 // helpers implement a type-safe object path system for nested fields.
...@@ -115,8 +116,8 @@ const mutDeleteItem = mutations.define({...@@ -115,8 +116,8 @@ const mutDeleteItem = mutations.define({
115 // Example: `Successfully {description}`116 // Example: `Successfully {description}`
116 describeResult: ({ get, args: [id] }) => "Deleted Item",117 describeResult: ({ get, args: [id] }) => "Deleted Item",
117 118
118 // Since the optimistic handler is perfect, there is no need to refetch any119 // Since this optimistic handler above is perfect, we can decide to disable
119 // data once a success case is hit. This defaults to false for simplicity.120 // success-based refetching. This is default so that more things just work.
120 refetchOnSuccess: false,121 refetchOnSuccess: false,
121});122});
122123