How to use set with dgraph when defining string id in graphql

Hi @amaster507,

Just to clarify, one should not be mixing graphql± with GraphQL. For example, in your case, you have @id on username, GraphQL will respect it, but graphql± won’t unless you write a correct upsert mutation for it. It is expected that you would either be using GraphQL or graphql± as the query language of your choice, not both of them together. They have their own capabilities, like GraphQL has got interfaces but ± doesn’t. On the other hand, graphql± allows you to write your own queries, while in GraphQL you can only use one of the pre-defined queries.

But, if you really want to use both of them together, then this is the mutation for your case:

{
  set {
    _:user-1 <dgraph.type> "User" .
    _:user-1 <User.username> "anthony" .
    _:user-1 <User.isContact> _:user-1C .
    _:user-1C <dgraph.type> "Contact" .
    _:user-1C <Contact.name> "Anthony Master" .
  }
}
1 Like