This looks odd. It should be like:
mu.setSetJson({
'bar': [{'uid': 'uid(bar2)'}], #be careful here, make sure it is ONE to ONE
'dgraph.type': 'Foo',
});
As bar is an Edge connecting to another object. This feels like a bug. But for now, fix the syntax to the one I mentioned above.
Do you really need to pass 'dgraph.type': 'Foo' all the time? You should add it in the creation, not in an upsert. But if you are creating it during the upsert, It is fine. Just a small thing, not important.
Line 99
I’m not sure what you are doing in that line. You say “Switch to bar 3” is it a migration of nodes to other references? You should unlink the others if it is a migration.
Fix the syntax there.
Also, if you have a lot of foos foo as var(func: type(Foo)) you will link them all in that upsert. That might be there the issue.
Maybe is the mutation syntax. Check it and let me know.