# Deep Mutations - Graphql

**URL:** <https://discuss.dgraph.io/t/deep-mutations-graphql/9789>\
**Category:** GraphQL\
**Tags:** status:accepted, ticket:created\
**Created:** [August 28, 2020, 5:23pm UTC](https://discuss.dgraph.io/t/deep-mutations-graphql/9789 "2020-08-28T17:23:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [August 28, 2020, 5:23pm UTC](https://discuss.dgraph.io/t/deep-mutations-graphql/9789/1 "2020-08-28T17:23:46Z")

</div>

Mutations also allows to perform deep mutation at multiple levels.

We use the following schema to demonstrate some examples.

## **Schema** :

```graphql
type Author {
	id: ID!
	name: String! @search(by: [hash])
	dob: DateTime
	posts: [Post]
}
type Post {
	postID: ID!
	title: String! @search(by: [term, fulltext])
	text: String @search(by: [fulltext, term])
	datePublished: DateTime
}

```

### **Example** : Deep Deep mutation using variables

```graphql
mutation DeepAuthor($author: DeepAuthorInput!) {
  DeepAuthor(input: [$author]) {
    author {
      id
      name
      post {
        title
        text
      }
    }
  }
}

```

Variables:

```json
{ "author":
  { "name": "A.N. Author",
    "dob": "2000-01-01",
    "posts": [
      {
        "title": "New post",
        "text": "A really new post"
      }
    ]
  }
}

```

### **Example** : Deep update mutation using variables

```graphql
mutation updateAuthor($patch: UpdateAuthorInput!) {
  updateAuthor(input: $patch) {
    author {
      id
      post {
        title
        text
      }
    }
  }
}

```

Variables:

```json
{ "patch":
  { "filter": {
      "id": ["0x123"]
    },
    "set": {
      "posts": [ {
        "postID": "0x456",
        "title": "A new title",
        "text": "Some edited text"
      } ]
    }
  }
}

```

* * *
This is a companion discussion topic for the original entry at [https://dgraph.io/docs/graphql/mutations/deep/](https://dgraph.io/docs/graphql/mutations/deep/)

---

<div class="post-metadata">

**Author:** ![JatinDevDG](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/jatindevdg/32/3417_2.png) [@JatinDevDG](https://discuss.dgraph.io/u/JatinDevDG)\
**Post date:** [November 18, 2020, 7:03am UTC](https://discuss.dgraph.io/t/deep-mutations-graphql/9789/2 "2020-11-18T07:03:45Z")

</div>

Deep update mutations are not supported in GraphQl. Also, there is no mutation named `DeepAuthor`.We should fix these docs.

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [December 15, 2020, 10:00pm UTC](https://discuss.dgraph.io/t/deep-mutations-graphql/9789/4 "2020-12-15T22:00:39Z")

</div>

hmm, I don’t know why I still find myself trying to update nested data. Maybe because the docs still says it should, but it doesn’t. Now, to rebuild my mutation to update the nested data in sibling mutations instead of deep mutations.

---

<div class="post-metadata">

**Author:** ![JatinDevDG](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/jatindevdg/32/3417_2.png) [@JatinDevDG](https://discuss.dgraph.io/u/JatinDevDG)\
**Post date:** [December 16, 2020, 5:16am UTC](https://discuss.dgraph.io/t/deep-mutations-graphql/9789/5 "2020-12-16T05:16:11Z")

</div>

yeah , docs are not updated yet. But a PR is already for it raised and will be merged soon.

---

<div class="post-metadata">

**Author:** ![acarey](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/acarey/32/7089_2.png) [@acarey](https://discuss.dgraph.io/u/acarey)\
**Post date:** [December 18, 2020, 7:07pm UTC](https://discuss.dgraph.io/t/deep-mutations-graphql/9789/6 "2020-12-18T19:07:00Z")

</div>

Hi, Everyone! Updated docs for deep mutations are now available: [https://dgraph.io/docs/master/graphql/mutations/deep/](https://dgraph.io/docs/master/graphql/mutations/deep/). These will be merged to the 20.11 docs branch soon. Thank you!
