New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setSetJson() does not support named blank nodes #59
Comments
Are you parsing the obj to JSON? it's not clear from your example. This should be the valid JSON.
Also, from your test is it working without blank nodes? |
Thanks for the fast response! It is sent just like in the examples (if I send a pure JSON string it chokes of course). const node = {
uid: '_:somename',
description: 'Describe thing',
aDate: '2019-07-02T04:00:00.000Z'
};
const mutation = new dgraph.Mutation();
mutation.setSetJson(node);
const done = await txn.mutate(mutation); If I leave the uid field out the blank nodes come back fine via |
I've did a quick test here and your example is working normally. I thought you were doing something else. BTW - Ratel uses the HTTP API not any JS client. const dgraph = require("dgraph-js");
// Create a client stub.
function newClientStub() {
return new dgraph.DgraphClientStub("localhost:9080");
}
// Create a client.
function newClient(clientStub) {
return new dgraph.DgraphClient(clientStub);
}
async function createData(dgraphClient) {
// Create a new transaction.
const txn = dgraphClient.newTxn();
try {
// Create data.
const p = {
uid: '_:somename',
description: 'Describe thing',
aDate: '2019-07-02T04:00:00.000Z'
};
// Run mutation.
const mu = new dgraph.Mutation();
mu.setSetJson(p);
const assigned = await txn.mutate(mu);
// Commit transaction.
await txn.commit();
console.log(`Created person named "somename" with uid = ${assigned.getUidsMap().get("somename")}\n`);
console.log("All created nodes (map from blank node names to uids):");
assigned.getUidsMap().forEach((uid, key) => console.log(`${key} => ${uid}`));
console.log();
} finally {
// Clean up. Calling this after txn.commit() is a no-op
// and hence safe.
await txn.discard();
}
}
async function main() {
const dgraphClientStub = newClientStub();
const dgraphClient = newClient(dgraphClientStub);
await createData(dgraphClient);
// Close the client stub.
dgraphClientStub.close();
}
main().then(() => {
console.log("\nDONE!");
}).catch((e) => {
console.log("ERROR: ", e);
}); |
Interesting! Are you using 1.1? I’m on 1.0.16
…On Sat, Jul 13, 2019 at 5:15 PM Michel Conrado ***@***.***> wrote:
Closed #59 <#59>.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#59?email_source=notifications&email_token=AADMY64QSCYZ5MZ3LE3OEJTP7JAXNA5CNFSM4IC6XCYKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOSPQLCNI#event-2480976181>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADMY6YLD6GRQDV2CXNPZADP7JAXNANCNFSM4IC6XCYA>
.
|
I'm using Dgraph from Master.
|
I've just tested on v1.0.16 and is working.
|
Oh wow! I owe you a beer! It turns out that a query that happens after the mutation but in the same transaction is where the issue was! I tested with your code and of course it worked....The blank node was making its way into the query: Thanks for all your effort looking into this, super appreciated!!! |
I'm getting errors when running a mutation with a named blank node via the dgraph-js client (same works in ratel)
this adds a bunch of impedance when writing dependant mutations...
The text was updated successfully, but these errors were encountered: