> For the complete documentation index, see [llms.txt](https://yeti-dev.gitbook.io/apollo-server-adonis-directive-pack/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yeti-dev.gitbook.io/apollo-server-adonis-directive-pack/api/mutation/update.md).

# @update

{% hint style="warning" %}
Required arguments for writing a mutation:

* id - Int! / \[Int!]! / String! / \[String!]! / ID! / \[ID!]!
* input - type Input or type Input (array)
  {% endhint %}

### For a separate add use

```javascript
/* ... */
const {
  UpdateDirective,
  UpdateTypeDefs
} = require('apollo-server-adonis-directives-pack/src/directives/mutation/Update')

makeExecutableSchema({ 
  /* ... */ 
  typeDefs: [ UpdateTypeDefs, /* ... */ ],
  schemaDirectives: { UpdateDirective, /* ... */} 
})
```

### Definition

{% code title="UpdateTypeDefs" %}

```graphql
directive @update(
  # By default, the model will be calculated from the name
  # of the returned "type" with the prefix 'App/Model/'
  model: String) on FIELD_DEFINITION
```

{% endcode %}

{% hint style="success" %}
:thinking: Carefully describe the mutation!

If you assign a different set to the input and output, this will throw an exception

> :exclamation: Error: Different sets are installed for input and output.
> {% endhint %}

{% hint style="info" %}
Update directive updates by primary key of model
{% endhint %}

### Example

```graphql
input UpdatePostInput {
    name: String
    text: String!
}

type Mutation {
    updatePost(id: String!, input: UpdatePostInput! ): Post @update
    updateManyPost(id: [String!]!, input: UpdatePostInput!): [Post] @update
}
```


---

# 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:

```
GET https://yeti-dev.gitbook.io/apollo-server-adonis-directive-pack/api/mutation/update.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
