# Adding a child of a one to many relationship while updating the parent

**URL:** <https://discuss.dgraph.io/t/adding-a-child-of-a-one-to-many-relationship-while-updating-the-parent/15287>\
**Category:** GraphQL\
**Tags:** mutation\
**Created:** [August 13, 2021, 6:48pm UTC](https://discuss.dgraph.io/t/adding-a-child-of-a-one-to-many-relationship-while-updating-the-parent/15287 "2021-08-13T18:48:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marco\_Antonio](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/marco_antonio/32/8361_2.png) [@Marco\_Antonio](https://discuss.dgraph.io/u/Marco_Antonio)\
**Post date:** [August 13, 2021, 6:48pm UTC](https://discuss.dgraph.io/t/adding-a-child-of-a-one-to-many-relationship-while-updating-the-parent/15287/1 "2021-08-13T18:48:10Z")

</div>

My db has this kind of schema:

```auto
type Parent{
    nome: String! @id
    children: [Child]! @hasInverse(field: parent)
}

type Child{
    nome: String! @id 
    parent: Parent!
}

```

First, I’m populating the database by the parents.  
Next, I want to populate the children while updating the parents.

How would I do that using mutations on GraphQL?

---

<div class="post-metadata">

**Author:** ![catherineluse](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/catherineluse/32/4329_2.png) [@catherineluse](https://discuss.dgraph.io/u/catherineluse)\
**Post date:** [August 13, 2021, 7:14pm UTC](https://discuss.dgraph.io/t/adding-a-child-of-a-one-to-many-relationship-while-updating-the-parent/15287/2 "2021-08-13T19:14:21Z")

</div>

You can do a mutation like this:

```auto
mutation {
  updateParent( input: { 
        filter: { 
          nome: ["parent-ID"] 
        },
        set: { 
            children: [{nome: "example"}],
        }
    }) {
      parent {
        nome
        children {
          nome
        }
      }
    }
  }

```

---

<div class="post-metadata">

**Author:** ![Marco\_Antonio](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/marco_antonio/32/8361_2.png) [@Marco\_Antonio](https://discuss.dgraph.io/u/Marco_Antonio)\
**Post date:** [August 13, 2021, 8:27pm UTC](https://discuss.dgraph.io/t/adding-a-child-of-a-one-to-many-relationship-while-updating-the-parent/15287/3 "2021-08-13T20:27:32Z")

</div>

I see  
I was imagining from the documentation that it would be only this way, going from top to bottom.

Thanks a lot!
