> For the complete documentation index, see [llms.txt](https://sync.objectbox.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sync.objectbox.io/sync-server/graphql-database/graphql-mutations.md).

# GraphQL Mutations

Note: The GraphQL playground can also be used for mutations.

### How to write mutations

#### Mutation name

There are mutation operations for all entity types. For each entity, the following mutations are available: put\* and delete\*, where \* signifies entity name. So for a `TestEntity`, the available mutations are `putTestEntity`, `deleteTestEntity`.

#### Arguments

All ObjectBox GraphQL mutations require an argument. For put operations, we indicate the types and values of objects to put, while when deleting we indicate the ids of objects to be deleted, or use the `all` flag to delete all objects. Refer to the examples below to see how these have to be formatted in each case.

#### Rerurn ID(s)

Optionally, you can use the `returning` section to make your mutation return the ID(s) of object(s) that were put or deleted.

### Examples of mutations

#### Put new or existing object

To put an object into the ObjectBox database, use `putTestEntity` for an ObjectBox entity called TestEntity, providing the object's type and value inside an `input` argument. This works both for putting new objects and updating existing ones (in the latter case an `id` must be supplied).

```
mutation putOne {
  putTestEntity(
    input: {simpleBoolean: true}
  ) {
    returning {
      id
    }
  }
}
```

#### Put multiple objects

`input` can also be an array.

```
mutation putMultiple {
  putTestEntity(
    input: [
      {simpleString: "banana"}, 
      {simpleString: "orange"}, 
      {simpleString: "banana"}
      ]) {
    returning {
      id
    }
  }
}
```

#### Delete

Supply an array of IDs to be deleted.

```
mutation deleteById {
    deleteTestEntity(ids: [1, 3, 4, 42]) {
        id
    }
}
```

#### Delete all

To delete all objects, set the `all` argument to `true`.

```
mutation deleteAll {
    deleteTestEntity(all: true) {
        id
    }
}
```

####


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://sync.objectbox.io/sync-server/graphql-database/graphql-mutations.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
