<p>To edit an entry via a GraphQL mutation you will need to pass the <code>id</code> of the entry you want to edit (similar to <a href="https://craftcms.com/knowledge-base/entry-form#editing-existing-entries" rel="nofollow noreferrer">front end entry form</a>).</p>
<p>This example assumes a <code>news</code> Section, an <code>article</code> Entry Type and will update the entry title.</p>
<p><strong>Mutation</strong></p>
<pre><code>mutation MyMutation($id: ID = &quot;&quot;, $title: String = &quot;&quot;) {
  save_news_article_Entry(id: $id, title: $title) {
    id
    title
  }
}
</code></pre>
<p><strong>Query variables</strong></p>
<pre class="lang-json prettyprint-override"><code>{
  &quot;id&quot;: &quot;12345&quot;,
  &quot;title&quot;: &quot;My title update&quot;
}
</code></pre>

CC BY-SA 4.0
2020-12-15T09:44:37.593Z
This should be runnable in the "Explore the GraphQL API" executor, right? 

Because it seems to do nothing, I'm passing in the id (605, from the url of that entry page) but I just get `{
  "data": []
}` in return.
jishi
CC BY-SA 4.0
2020-12-15T09:59:16.237Z
Did you change `save_news_article_Entry` to match your entry section and type? So `save_yourSectionHandle_yourEntrytypeHandle_Entry`.
Oli
CC BY-SA 4.0
2020-12-15T10:03:46.523Z
Yeah, I'm using `save_lovstaStuteriStallions_hingstsida_Entry` to match the handle of the section, and the handle of the entry type. Just realized that it works with the Full Schema, and I had forgotten to check the "save entries" under the mutation permission, only had the parent "edit entries" permission checked. Not sure about the purpose of the parent "Edit" checkbox if you still need one of the child permissions selected anyway... ?
jishi
CC BY-SA 4.0
2020-12-15T10:27:18.033Z
It's mostly for grouping purposes. Glad it's working for you though!
Oli
CC BY-SA 4.0
2020-12-15T05:51:50.433Z
2020-12-15T06:05:30.120Z
2020-12-15T06:05:30.120Z
Oli
<p>I'm trying out the GraphQL mutations and would like to issue an update of an Entry, triggered from a webhook.</p>
<p>However, documentation on mutations seems sparse, and I find GraphQL highly confusing. Most examples talk about creating new entries, not update current ones, and how you actually call graphQL relies on implementation, it's hard to figure out how to deal with this in Craft.</p>
<p>I found <a href="https://github.com/craftcms/cms/issues/4835" rel="nofollow noreferrer">https://github.com/craftcms/cms/issues/4835</a>, which shows an example of creating an entry. Documentation talks about creating drafts, and publishing drafts, but no examples are shown, just a bunch of words thrown around.</p>
<p>First it says:</p>
<blockquote>
<p>To save a draft for an entry, use the entry type-specific mutation which will have the name in the form of save___Draft</p>
</blockquote>
<p>But then followed by:</p>
<blockquote>
<p>To create a draft use the createDraft mutation., which requires the id of the entry for which to create the draft as an argument and returns the resulting id of the draft as the result.</p>
</blockquote>
<blockquote>
<p>For publishing a draft, you should use the publishDraft mutation, which requires the id of the draft to publish as an argument and returns the id of the entry it belongs to as the result.</p>
</blockquote>
<p>None of these things makes sense to me...</p>
<p>Anyone have any comprehensible examples they can give?</p>

<graphql>
Updating Entry field with GraphQL mutation
# Updating Entry field with GraphQL mutation

(Asked by: username_0 on 2020-12-14)

I'm trying out the GraphQL mutations and would like to issue an update of an Entry, triggered from a webhook.

However, documentation on mutations seems sparse, and I find GraphQL highly confusing. Most examples talk about creating new entries, not update current ones, and how you actually call graphQL relies on implementation, it's hard to figure out how to deal with this in Craft.

I found <https://github.com/craftcms/cms/issues/4835>, which shows an example of creating an entry. Documentation talks about creating drafts, and publishing drafts, but no examples are shown, just a bunch of words thrown around.

First it says:

> To save a draft for an entry, use the entry type-specific mutation which will have the name in the form of save\_\_\_Draft

But then followed by:

> To create a draft use the createDraft mutation., which requires the id of the entry for which to create the draft as an argument and returns the resulting id of the draft as the result.

> For publishing a draft, you should use the publishDraft mutation, which requires the id of the draft to publish as an argument and returns the id of the entry it belongs to as the result.

None of these things makes sense to me...

Anyone have any comprehensible examples they can give?

**Tags:** graphql


---

## 1 answers

### Answer by username_1 on 2020-12-15. Score: 3 | Accepted answer

To edit an entry via a GraphQL mutation you will need to pass the id of the entry you want to edit (similar to front end entry form).
This example assumes a news Section, an article Entry Type and will update the entry title.
Mutation
mutation MyMutation($id: ID = "", $title: String = "") {
  save_news_article_Entry(id: $id, title: $title) {
    id
    title
  }
}

Query variables
{
  "id": "12345",
  "title": "My title update"
}

> **Comments:**
> **username_0**: This should be runnable in the "Explore the GraphQL API" executor, right?   Because it seems to do nothing, I'm passing in the id (605, from the url of that entry page) but I just get `{   "data": [] }` in return.  
> **username_1**: Did you change `save_news_article_Entry` to match your entry section and type? So `save_yourSectionHandle_yourEntrytypeHandle_Entry`.  
> **username_0**: Yeah, I'm using `save_lovstaStuteriStallions_hingstsida_Entry` to match the handle of the section, and the handle of the entry type. Just realized that it works with the Full Schema, and I had forgotten to check the "save entries" under the mutation permission, only had the parent "edit entries" permission checked. Not sure about the purpose of the parent "Edit" checkbox if you still need one of the child permissions selected anyway... ?  
> **username_1**: It's mostly for grouping purposes. Glad it's working for you though!  

---

