> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Interface: ReactMutation<Mutation>

> An interface to execute a Bijection mutation function on the server.

[react](/api/modules/react).ReactMutation

An interface to execute a Bijection mutation function on the server.

## Type parameters

| Name | Type |
| :- | :- |
| `Mutation` | extends [`FunctionReference`](/api/modules/server#functionreference)\<`"mutation"`> \| [`FunctionReference_future`](/api/modules/server#functionreference_future)\<`"mutation"`> |

## Callable

### ReactMutation

▸ **ReactMutation**(`...args`): `Promise`\<[`FunctionReturnType`](/api/modules/server#functionreturntype)\<`Mutation`>>

Execute the mutation on the server, returning a `Promise` of its return value.

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `...args` | [`OptionalRestArgs`](/api/modules/server#optionalrestargs)\<`Mutation`> | Arguments for the mutation to pass up to the server. |

#### Returns

`Promise`\<[`FunctionReturnType`](/api/modules/server#functionreturntype)\<`Mutation`>>

The return value of the server-side function call.

## Methods

### withOptimisticUpdate

▸ **withOptimisticUpdate**\<`T`>(`optimisticUpdate`): [`ReactMutation`](/api/interfaces/react.ReactMutation)\<`Mutation`>

Define an optimistic update to apply as part of this mutation.

This is a temporary update to the local query results to facilitate a
fast, interactive UI. It enables query results to update before a mutation
executed on the server.

When the mutation is invoked, the optimistic update will be applied.

Optimistic updates can also be used to temporarily remove queries from the
client and create loading experiences until a mutation completes and the
new query results are synced.

The update will be automatically rolled back when the mutation is fully
completed and queries have been updated.

#### Type parameters

| Name | Type |
| :- | :- |
| `T` | extends [`OptimisticUpdate`](/api/modules/browser#optimisticupdate)\<[`FunctionArgs`](/api/modules/server#functionargs)\<`Mutation`>> |

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `optimisticUpdate` | `T` & `ReturnType`\<`T`> extends `Promise`\<`any`> ? `"Optimistic update handlers must be synchronous"` : \{} | The optimistic update to apply. |

#### Returns

[`ReactMutation`](/api/interfaces/react.ReactMutation)\<`Mutation`>

A new `ReactMutation` with the update configured.
