Where is the query? I think you are not using Upsert correctly. You should have a query and also use variables. Maybe you have stepped into the Upsert Directive docs. Which is not the same as Upsert Block. See the examples bellow.
I must admit I don’t even understand the docs my example above works perfectly fine,
for example, if I create the parent beforehand and add a uid field to the parent with the uid of the node I can achieve what I want.
In general, I was wondering if there is a way to avoid that initial creation of the parent node because its much more effort to inject an uid field in the json array at every parent object.
I was wondering if it might be possible to set a constraint on the containerId which would lead dgraph to automatically resolve the fact that there should be only one node with that exact containerID
will create one new node, and link the parent field to the existing Container with containerId “parent1”.
However, the “parent1” Container still only has a containerId field, it does not have a name – you need to upsert that information separately if needed.
In any case, this approach allows you to create unique nodes per containerId, and it also automatically creates an empty-ish parent node, so you don’t need to inject any UIDs anywhere, and can manage your data completely from business key land.