I want to change the device owner - from foo to bar, so I run the upsert
query {
device as var(func: eq(uuid, "baz")
owner as var(func: eq(uuid, "bar")
}
mutation {
set {
uid(device) <owner> uid(owner) .
}
}
The question is if it is right to make upsert in this way? Because after this upsert relation between baz-device and foo-owner still exists
Or should I delete old relation and only then add a new one?
The mutation that you are doing is adding a new relation independent of the older relations. If you want to remove some relation then you should delete it as well.
Then I have another problem: if I delete and set in the same mutation and old and new owners are the same, then delete overwrites set. So I lose relation between device and owner.
What to do in this case?
Hey @poketulhu, your mutation looks good to me. Ideally, your mutation should set the <owner> to the new owner and delete the reverse edge for the previous owner to the device. There is a bug that @reverse edge is not being updated correctly which @ppp225 has pointed out.