Using JSON mutation with the Go client, I’d like to be able to create edges from a reversed predicate.
For instance, if I have the following models:
type Person struct {
Id string `json:"uid,omitempty"`
Name string `json:"name,omitempty"`
Bike *Bike `json:"owns,omitempty"`
}
type Bike struct {
Id string `json:"uid,omitempty"`
Brand string `json:"brand,omitempty"`
Owner *Person `json:"~owns,omitempty"`
}
I can easily create a Person that owns a bike with the following mutation model:
Nevermind, I just understood how to correlate IDs using Id: "_:my-key" and then reuse _:my-key wherever I need to reference the same new ID. That way I can do a single mutation with an array of several different models referencing each others.
That way I only do one call to dGraph.
In this basic example it could have been done in a simpler manner but when you have several reverse predicates, you cannot create all your nodes with a single mutation.
JSON mutations are only available via gRPC clients, such as the Go client, JS client, and Java client. They’re not available via the raw HTTP interface.