Hi, I was hoping to upsert a multiple nodes at once. For example, I want to supply a graph that has a parent and two children. The upsert would populate any of those nodes that did not exist, and update the nodes that did exist.
Using the upsert block I was able to pull this off with graphs that had single children in the relationship, but am now stuck when there’s multiple children. I want to write something like so:
upsert {
query {
q(func: eq(name, "parent1")) {
v as uid
name
has_child @filter(eq(name, "child1")){
v2 as uid
}
has_child @filter(eq(name, "child2")){
v3 as uid
}
}
}
mutation {
set {
uid(v) <name> "parent1" .
uid(v) <has_child> uid(v2) .
uid(v) <has_child> uid(v3) .
uid(v2) <name> "child1" .
uid(v3) <name> "child2" .
}
}
}
However specifying multiple <has_child> relationships is forbidden. What would be the most idiomatic way to solve this?
@MichelDiz Ahh awesome thanks! I actually tried that with the has_child2 AS has_child syntax but I see thats for variablizing and not aliasing. Works great