grandstack add mutation with relationship

145 Views Asked by At

i'm able to call a mutation in order to insert a node, but what if i want to insert the relationship with another node as well?

I saw that the grandstack has generated some mutations of this type: AddGroupUsers

How can i call this mutation togeder with the node insert mutation? a sort of transaction? is it possible? Does it exist a way to define the relationship with the node in the same mutation?

1

There are 1 best solutions below

4
On

You can provide several operations in Graphql in the following way:

mutation($name: String!, $login: String!) {
  CreateRepository(name: $name) {
    name
  }
  AddRepositoryOwner(from: { login: $login }, to: { name: $name }) {
    from {
      login
    }
    to {
      name
    }
  }
}

Also providing the variables:

{
    variables: {
        login: "login",
        name: "name",
    }
}

That's the closest to what you want to achieve I am aware of.