Skip to content

Commit c574370

Browse files
docs: document mutations params argument (#259)
Co-authored-by: michael-small <33669563+michael-small@users.noreply.github.com>
1 parent 38e178a commit c574370

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

docs/docs/mutations.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,12 @@ httpMutation({
143143
144144
### Callbacks
145145
146-
In the mutation: _optional_ `onSuccess` and `onError` callbacks
146+
In the mutation: _optional_ `onSuccess` and `onError` callbacks.
147+
148+
The callbacks are called with two parameters:
149+
150+
1. The result of the mutation (`onSuccess`) or the error (`onError`)
151+
2. The parameter passed when calling the mutation
147152
148153
```ts
149154
({
@@ -159,6 +164,14 @@ In the mutation: _optional_ `onSuccess` and `onError` callbacks
159164
console.error('Error occurred:', error);
160165
},
161166
});
167+
168+
// using the passed parameter
169+
({
170+
onSuccess: (_result, params) => {
171+
// after successful deletion
172+
store.listResource.set(store.listResource.value().filter((item) => item.id !== params.id));
173+
},
174+
});
162175
```
163176

164177
### Flattening operators

0 commit comments

Comments
 (0)