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({
8787 // `optimistic` is provided a `helpers` object which implement automatic rollbacks.
8888 optimistic({ client, get, helpers, args: [id], onSuccess, onRestore, onRefetch }) {
8989 // 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.
9091 helpers.arrayRemove(queryItemList, (item) => item === id);
9192 // Set a property on an object, also restores and refetches. The `obj`
9293 // helpers implement a type-safe object path system for nested fields.
......@@ -115,8 +116,8 @@ const mutDeleteItem = mutations.define({
115116 // Example: `Successfully {description}`
116117 describeResult: ({ get, args: [id] }) => "Deleted Item",
117118
118 // Since the optimistic handler is perfect, there is no need to refetch any
119 // data once a success case is hit. This defaults to false for simplicity.
119 // Since this optimistic handler above is perfect, we can decide to disable
120 // success-based refetching. This is default so that more things just work.
120121 refetchOnSuccess: false,
121122});
122123