# Send Mutation Requests

| AVAILABLE API VERSION               |
| ----------------------------------- |
| Beta v59.0–65.0                     |
| Generally Available v66.0 and later |

A mutation request modifies your record data by either creating, updating, or deleting the data. When you send a [record create request](/docs/platform/graphql/guide/mutations-create.md), you can also request for fields from the newly created record in one request. However, you can’t query fields with record [update](/docs/platform/graphql/guide/mutations-update.md) and [delete](/docs/platform/graphql/guide/mutations-delete.md) requests.

Your request can fail if you have multiple fields with the same name, which results in naming conflicts. To avoid conflicts, use [aliases](https://graphql.org/learn/queries/#aliases) to rename the result of a field.

```sfdocs-code {"lang":"graphql", "title": "Aliases Syntax", "src": "" }
first: AccountCreate(input: { ... })
second: AccountCreate(input: { ... })
```

## All or None Requests

The `uiapi` field of `UIAPIMutations` type has an input field for an `allOrNone` boolean argument. The default is `true`.

```sfdocs-code {"lang":"graphql", "title": "allOrNone Syntax", "src": "" }
mutation OperationName {
  uiapi(input: { allOrNone: false }) {
    first: AccountCreate(input: { ... })
    second: AccountCreate(input: { ... })
  }
}
```

When `allOrNone` is `true`, all operations are rolled back if any operation fails, or all operations are executed within a transaction. When `allOrNone` is set to `false`, only operations that fail are rolled back along with any operations that depend on those failed operations, allowing other successful operations to execute.

### Example: Successful Multiple Account Creation

If you set `allOrNone` to `false` when creating multiple accounts, a failed operation doesn’t prevent the other operations from successfully executing. In this example, the second operation successfully executes while the first one fails.

```sfdocs-code {"lang":"graphql", "title": "Multiple Account Creation with allOrNone (false)", "src": "" }
mutation MutipleAccounts{
  uiapi(input: { allOrNone: false }) {
    AccountCreate(input: {
      Account: {
        NumberOfEmployees: 100
      }
    }) {
      Record {
        Id
        Name { value }
      }
    }
    second: AccountCreate(input: {
      Account: {
        Name: "Amazing Account"
      }
    }){
      Record {
        Id
        Name { value }
      }
    }
  }
}
```

The response looks like this.

```sfdocs-code {"lang":"json", "title": "Response for Successful Multiple Account Creation", "src": "" }
{
  "data": {
    "uiapi": {
      "AccountCreate": null,
      "second": {
        "Record": {
          "Id": "001RM000005eoXGYAY",
          "Name": {
            "value": "Amazing Account"
          }
        }
      }
    }
  },
  "errors": [
    {
      "extensions": {
        "ErrorType": "DataFetchingException"
      },
      "locations": [
        {
          "column": 5,
          "line": 3
        }
      ],
      "message": "Required fields are missing: [Name]",
      "paths": ["uiapi", "AccountCreate"]
    }
  ]
}
```

### Example: Unsuccessful Multiple Account Creation

If `allOrNone` is `true` when you’re creating multiple accounts, all account creation fails if any single operation fails. In this example, the first account create operation fails because `Name` if a required field on accounts, so the other operation also fails.

```sfdocs-code {"lang":"graphql", "title": "Multiple Account Creation with allOrNone (true)", "src": "" }
mutation MutipleAccounts{
  uiapi(input: { allOrNone: true }) {
    AccountCreate(input: {
      Account: {
        NumberOfEmployees: 100
      }
    }) {
      Record {
        Id
        Name { value }
      }
    }
    second: AccountCreate(input: {
      Account: {
        Name: "Amazing Account"
      }
    }){
      Record {
        Id
        Name { value }
      }
    }
  }
}
```

The response looks like this.

```sfdocs-code {"lang":"json", "title": "Response for Unsuccessful Multiple Account Creation", "src": "" }
{
  "data": {
    "uiapi": {
      "AccountCreate": null,
      "second": null
    }
  },
  "errors": [
    {
      "extensions": {
        "ErrorType": "DataFetchingException"
      },
      "locations": [
        {
          "column": 5,
          "line": 3
        }
      ],
      "message": "Required fields are missing: [Name]",
      "paths": ["uiapi", "AccountCreate"]
    },
    {
      "extensions": {
        "ErrorType": "DataFetchingException"
      },
      "locations": [
        {
          "column": 5,
          "line": 13
        }
      ],
      "message": "The transaction was rolled back since another operation in the same transaction failed.",
      "paths": ["uiapi", "second"]
    }
  ]
}
```

## Order of Operations

The order of operations depends on each operation’s dependencies. To enable an operation to use a field from another operation in the same execution, use the `@{alias}` syntax. See [Mutation Field References](/docs/platform/graphql/guide/mutations-references.md).

```sfdocs-code {"lang":"graphql", "title": "Dependent Field Syntax", "src": "" }
FieldName: "@{aliasName}"
```

### Example: Multiple Account Creation and Updates

You can create multiple accounts and update them in a single request. The update operation requires the `Id` field value from the create operation. In this example, the account create operation with the `second` alias is successful, followed by a successful update on the same account. The first account create fails because a required field is missing.

```sfdocs-code {"lang":"graphql", "title": "Multiple Account Creation with Update", "src": "" }
mutation MutipleCreateWithUpdate{
  uiapi(input: { allOrNone: false }) {
    AccountCreate(input: {
      Account: {
        NumberOfEmployees: 100
      }
    }) {
      Record {
        Id
        Name { value }
      }
    }
    second: AccountCreate(input: {
      Account: {
        Name: "Amazing Account"
      }
    }){
      Record {
        Id
        Name { value }
      }
    }
    AccountUpdate(input: {
      Account: {
        Name: "Awesome Account"
      }
      Id: "@{second}"
    }) {
      Record {
        Id
        Name { value }
      }
    }
  }
}
```

The response looks like this.

```sfdocs-code {"lang":"json", "title": "Response for Account Creation with Update", "src": "" }
{
  "data": {
    "uiapi": {
      "AccountCreate": null,
      "second": {
        "Record": {
          "Id": "001RM000005eoYEYAY",
          "Name": {
            "value": "Amazing Account"
          }
        }
      },
      "AccountUpdate": {
        "Record": {
          "Id": "001RM000005eoYEYAY",
          "Name": {
            "value": "Amazing Account"
          }
        }
      }
    }
  },
  "errors": [
    {
      "extensions": {
        "ErrorType": "DataFetchingException"
      },
      "locations": [
        {
          "column": 5,
          "line": 3
        }
      ],
      "message": "Required fields are missing: [Name]",
      "paths": ["uiapi", "AccountCreate"]
    }
  ]
}
```
