Under what scenarios does Dgraph return an array in place of a string?

I haven’t (until now) tried mutating the predicate using an array in setJson. I wouldn’t have expected it to work. However, the results are the same with all four options below:

mu.setSetJson({
  bar: 'uid(bar2)',
});

mu.setSetJson({
  bar: {uid: 'uid(bar2)'},
});

mu.setSetJson({
  bar: ['uid(bar2)'],
});

mu.setSetJson({
  bar: [{uid: 'uid(bar2)'}],
});

That is, I sometimes get an array response to the query in postCommit and sometimes not.

No not in this case, it’s just habit on my part. A long while back I had forgotten it in a few places and a lot of stuff broke so now I’ve just been explicit every time.

I don’t know what you mean – I’m trying to replace the value in the predicate. Do I need to do a delete mutation and then a set mutation whenever I want to replace a value in a scalar/uid predicate?

Yeah – in this case, I have one, so I could make a (mostly) minimally reproducible demo. I’m more explicit in my real code.