Hi. Disclaimer: I’m working with NodeJs and the oficial javascript client.
I found it very error prone the way you get back the uids from a mutation.
Its a very common scenario to run a mutation ordered by the client and have to return the generated uids, so if the user wants to edit something right after he inserted it, the client interface can handle the task.
But, when I do a mutation it can contain a bunch of updates and inserts mixed as far the way dgraph goes, witch is GREAT in my opinion. The problem is that now I have to map the uids from the result, back to the client.
Picture this data send to server as an exemple:
d = {
user: "test",
uid: "0x1",
emails: [
{
email: 'test@mail.com'
}
]
}
In this simple case, if I send this json to a mutation I’ll be doing an update in user, as I’m providing a known UID, and inserting a new “email” along an edge “emails” conecting both.
When I get back the uids:
let res = await txn.mutate(upd);
uids = res.getUidsMap();
I got an array of “blanks-nn” that I’ll have to parse in order to figure out whos
who. If I’m misunderstanding something or just doing plain wrong, please do tell me, but I think the response of this mutation should be something like:
{
uid: "0x1",
emails: [
{
uid: 0x2
}
]
}
So I dont have to be guessing the map back and a simple:
_.merge(d, res);
would solve it.
Any thoughts?