# MutationConfig

Defined in: [react/src/types.ts:779](https://github.com/B3Pay/ic-reactor/blob/ad82a03d03149c25f0d0f63e453f62e284c28b02/packages/react/src/types.ts#L779)

Configuration for createMutation and useActorMutation.

## Extends

- `Omit`\<`UseMutationOptions`\<[`ReactorReturnOk`](https://ic-reactor.b3pay.net/v3/libs/type-aliases/reactorreturnok/)\<`Service`, `Method`, `Transform`\>, [`ReactorReturnErr`](https://ic-reactor.b3pay.net/v3/libs/type-aliases/reactorreturnerr/)\<`Service`, `Method`, `Transform`\>, [`ReactorArgs`](https://ic-reactor.b3pay.net/v3/libs/type-aliases/reactorargs/)\<`Service`, `Method`, `Transform`\>, `TOnMutateResult`\>, `"mutationFn"`\>

## Type Parameters

### Service

`Service` = [`BaseActor`](https://ic-reactor.b3pay.net/v3/libs/type-aliases/baseactor/)

### Method

`Method` *extends* [`FunctionName`](https://ic-reactor.b3pay.net/v3/libs/type-aliases/functionname/)\<`Service`\> = [`FunctionName`](https://ic-reactor.b3pay.net/v3/libs/type-aliases/functionname/)\<`Service`\>

### Transform

`Transform` *extends* [`TransformKey`](https://ic-reactor.b3pay.net/v3/libs/type-aliases/transformkey/) = `"candid"`

### TOnMutateResult

`TOnMutateResult` = `unknown`

The value `onMutate` returns, which `onSuccess`,
`onError` and `onSettled` receive. TypeScript infers it from `onMutate`.

## Properties

### functionName

> **functionName**: `Method`

Defined in: [react/src/types.ts:794](https://github.com/B3Pay/ic-reactor/blob/ad82a03d03149c25f0d0f63e453f62e284c28b02/packages/react/src/types.ts#L794)

The method to call on the canister

***

### callConfig?

> `optional` **callConfig?**: `CallConfig`

Defined in: [react/src/types.ts:796](https://github.com/B3Pay/ic-reactor/blob/ad82a03d03149c25f0d0f63e453f62e284c28b02/packages/react/src/types.ts#L796)

Call configuration for the actor method

***

### invalidateQueries?

> `optional` **invalidateQueries?**: [`InvalidationTarget`](https://ic-reactor.b3pay.net/v3/libs/type-aliases/invalidationtarget/)\<`Service`, `Transform`\>[]

Defined in: [react/src/types.ts:812](https://github.com/B3Pay/ic-reactor/blob/ad82a03d03149c25f0d0f63e453f62e284c28b02/packages/react/src/types.ts#L812)

Queries to invalidate upon successful mutation, before `onSuccess` runs.
The mutation stays pending until the invalidated queries in use have
refetched, so `onSuccess` reads the refetched data.

Each entry is a query key, a query object or query factory, or a
`{ functionName, args? }` method of this mutation's reactor; see
[InvalidationTarget](https://ic-reactor.b3pay.net/v3/libs/type-aliases/invalidationtarget/). `undefined` entries are skipped, so
`[maybeQuery]` is safe when the optional query object is absent.

#### Example

```typescript
invalidateQueries: [getPosts, { functionName: "get_posts_count" }]
```

***

### onCanisterError?

> `optional` **onCanisterError?**: (`error`, `variables`) => `void`

Defined in: [react/src/types.ts:835](https://github.com/B3Pay/ic-reactor/blob/ad82a03d03149c25f0d0f63e453f62e284c28b02/packages/react/src/types.ts#L835)

Callback for canister-level business logic errors.
Called when the canister returns a Result { Err: E } variant.

This is separate from `onError` which handles all errors including
network failures, agent errors, etc.

#### Parameters

##### error

[`CanisterError`](https://ic-reactor.b3pay.net/v3/libs/classes/canistererror/)\<[`TransformReturnRegistry`](https://ic-reactor.b3pay.net/v3/libs/interfaces/transformreturnregistry/)\<[`ErrResult`](https://ic-reactor.b3pay.net/v3/libs/type-aliases/errresult/)\<[`ActorMethodReturnType`](https://ic-reactor.b3pay.net/v3/libs/type-aliases/actormethodreturntype/)\<`Service`\[`Method`\]\>\>, `Service`\>\[`Transform`\]\>

The CanisterError containing the typed error value

##### variables

[`ReactorArgs`](https://ic-reactor.b3pay.net/v3/libs/type-aliases/reactorargs/)\<`Service`, `Method`, `Transform`\>

The arguments passed to the mutation

#### Returns

`void`

#### Example

```typescript
createMutation(reactor, {
  functionName: "transfer",
  onCanisterError: (error, variables) => {
    // error.err contains the typed Err value
    // error.code contains the variant key (e.g., "InsufficientFunds")
    console.error(`Transfer failed: ${error.code}`, error.err)
  },
})
```