The following code is intended to query a Dgraph server for the values associated with a specific node, similar to looking up a row by primary key in a relational database.
const dgraph = require("dgraph-js");
const grpc = require("grpc");
const clientStub = new dgraph.DgraphClientStub( grpc.credentials.createInsecure() );
const dgraphClient = new dgraph.DgraphClient(clientStub);
const lookupNode = `query nodeValues($id:uid) {
nodeValues(func: uid($id)) {
value1,
value2,
value3
}
}`;
const res = await dgraphClient.newTxn().queryWithVars(query, {$id: "0x13");
This raises Error: 2 UNKNOWN: Type "uid" not supported
when executing. If the $id
variable is typed as a string
or int
no results are found. How does one query by UID of a node with variables?