| ... | ... | @@ -87,6 +87,7 @@ const mutDeleteItem = mutations.define({ |
| 87 | 87 | // `optimistic` is provided a `helpers` object which implement automatic rollbacks. |
| 88 | 88 | optimistic({ client, get, helpers, args: [id], onSuccess, onRestore, onRefetch }) { |
| 89 | 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 | 91 | helpers.arrayRemove(queryItemList, (item) => item === id); |
| 91 | 92 | // Set a property on an object, also restores and refetches. The `obj` |
| 92 | 93 | // helpers implement a type-safe object path system for nested fields. |
| ... | ... | @@ -115,8 +116,8 @@ const mutDeleteItem = mutations.define({ |
| 115 | 116 | // Example: `Successfully {description}` |
| 116 | 117 | describeResult: ({ get, args: [id] }) => "Deleted Item", |
| 117 | 118 | |
| 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. |
| 120 | 121 | refetchOnSuccess: false, |
| 121 | 122 | }); |
| 122 | 123 | |