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

My db has this kind of schema:

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?

You can do a mutation like this:

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

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

Thanks a lot!