# setSetJson() does not support named blank nodes

**URL:** https://discuss.dgraph.io/t/setsetjson-does-not-support-named-blank-nodes/8176
**Category:** Dgraph Clients
**Tags:** untagged, dgraph-js
**Created:** [July 13, 2019, 4:05pm UTC](https://discuss.dgraph.io/t/setsetjson-does-not-support-named-blank-nodes/8176 "2019-07-13T16:05:07Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)
#### Post date: [July 13, 2019, 4:05pm UTC](https://discuss.dgraph.io/t/setsetjson-does-not-support-named-blank-nodes/8176/1 "2019-07-13T16:05:07Z")

</div>

**Moved from GitHub [dgraph-js/59](https://github.com/dgraph-io/dgraph-js/issues/59)**

_Posted by_ [jpstrikesback](https://github.com/jpstrikesback):

I’m getting errors when running a mutation with a named blank node via the dgraph-js client (same works in ratel)

```auto
{
  uid: '_:somename',
  description: 'Describe thing',
  aDate: '2019-07-02T04:00:00.000Z'
}

```

```auto
{
  error: Error: 2 UNKNOWN: strconv.ParseUint: parsing "_:somename": invalid syntax
      at Object.exports.createStatusError (/node_modules/grpc/src/common.js:91:15)
      at Object.onReceiveStatus (/node_modules/grpc/src/client_interceptors.js:1204:28)
      at InterceptingListener._callNext (/node_modules/grpc/src/client_interceptors.js:568:42)
      at InterceptingListener.onReceiveStatus (/node_modules/grpc/src/client_interceptors.js:618:8)
      at callback (/node_modules/grpc/src/client_interceptors.js:845:24) {
    code: 2,
    metadata: Metadata { _internal_repr: {} },
    details: 'strconv.ParseUint: parsing "_:somename": invalid syntax'
  }
}

```

this adds a bunch of impedance when writing dependant mutations…

---

<div class="post-metadata">

### Author: ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)
#### Post date: [July 13, 2019, 4:17pm UTC](https://discuss.dgraph.io/t/setsetjson-does-not-support-named-blank-nodes/8176/2 "2019-07-13T16:17:26Z")

</div>

[MichelDiz](https://github.com/MichelDiz) _commented_ :

Are you parsing the obj to JSON? it’s not clear from your example.

This should be the valid JSON.

```auto
{
	"uid": "_:somename",
	"description": "Describe thing",
	"aDate": "2019-07-02T04:00:00.000Z"
}

```

Also, from your test is it working without blank nodes?

---

<div class="post-metadata">

### Author: ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)
#### Post date: [July 13, 2019, 4:29pm UTC](https://discuss.dgraph.io/t/setsetjson-does-not-support-named-blank-nodes/8176/3 "2019-07-13T16:29:00Z")

</div>

[jpstrikesback](https://github.com/jpstrikesback) _commented_ :

Thanks for the fast response!

It is sent just like in the examples (if I send a pure JSON string it chokes of course).

```auto
    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 `done.getUidsMap().get('blank-0')`

---

<div class="post-metadata">

### Author: ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)
#### Post date: [July 13, 2019, 9:15pm UTC](https://discuss.dgraph.io/t/setsetjson-does-not-support-named-blank-nodes/8176/4 "2019-07-13T21:15:29Z")

</div>

[MichelDiz](https://github.com/MichelDiz) _commented_ :

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.

```auto

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);
});

```

---

<div class="post-metadata">

### Author: ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)
#### Post date: [July 13, 2019, 9:36pm UTC](https://discuss.dgraph.io/t/setsetjson-does-not-support-named-blank-nodes/8176/5 "2019-07-13T21:36:24Z")

</div>

[jpstrikesback](https://github.com/jpstrikesback) _commented_ :

Interesting! Are you using 1.1? I’m on 1.0.16

On Sat, Jul 13, 2019 at 5:15 PM Michel Conrado [notifications@github.com](mailto:notifications@github.com)  
wrote:

> Closed #59 [https://github.com/dgraph-io/dgraph-js/issues/59](https://github.com/dgraph-io/dgraph-js/issues/59).
> 
> —  
> You are receiving this because you authored the thread.  
> Reply to this email directly, view it on GitHub  
> [https://github.com/dgraph-io/dgraph-js/issues/59?email\_source=notifications&email\_token=AADMY64QSCYZ5MZ3LE3OEJTP7JAXNA5CNFSM4IC6XCYKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOSPQLCNI#event-2480976181](https://github.com/dgraph-io/dgraph-js/issues/59?email_source=notifications&email_token=AADMY64QSCYZ5MZ3LE3OEJTP7JAXNA5CNFSM4IC6XCYKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOSPQLCNI#event-2480976181),  
> or mute the thread  
> [https://github.com/notifications/unsubscribe-auth/AADMY6YLD6GRQDV2CXNPZADP7JAXNANCNFSM4IC6XCYA](https://github.com/notifications/unsubscribe-auth/AADMY6YLD6GRQDV2CXNPZADP7JAXNANCNFSM4IC6XCYA)  
> .

---

<div class="post-metadata">

### Author: ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)
#### Post date: [July 13, 2019, 9:59pm UTC](https://discuss.dgraph.io/t/setsetjson-does-not-support-named-blank-nodes/8176/6 "2019-07-13T21:59:01Z")

</div>

[MichelDiz](https://github.com/MichelDiz) _commented_ :

` "dgraph-js": "^1.3.0-rc1"`

I’m using Dgraph from Master.

```auto
Dgraph version : v1.0.12-rc3-571-ge4a07ad0
Commit SHA-1 : e4a07ad0
Commit timestamp : 2019-07-04 23:27:17 +0530
Branch : master
Go version : go1.12.6

```

---

<div class="post-metadata">

### Author: ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)
#### Post date: [July 13, 2019, 10:04pm UTC](https://discuss.dgraph.io/t/setsetjson-does-not-support-named-blank-nodes/8176/7 "2019-07-13T22:04:26Z")

</div>

[MichelDiz](https://github.com/MichelDiz) _commented_ :

I’ve just tested on v1.0.16 and is working.

```auto
Dgraph version : v1.0.16
Commit SHA-1 : 0590ee95
Commit timestamp : 2019-07-11 11:52:54 -0700
Branch : HEAD
Go version : go1.12.5

```

---

<div class="post-metadata">

### Author: ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)
#### Post date: [July 13, 2019, 10:43pm UTC](https://discuss.dgraph.io/t/setsetjson-does-not-support-named-blank-nodes/8176/8 "2019-07-13T22:43:44Z")

</div>

[jpstrikesback](https://github.com/jpstrikesback) _commented_ :

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: `func(uid(_:somename))...` and it was choking there. Ugh 😕

Thanks for all your effort looking into this, super appreciated!!!

---

<div class="post-metadata">

### Author: ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)
#### Post date: [July 11, 2020, 4:18am UTC](https://discuss.dgraph.io/t/setsetjson-does-not-support-named-blank-nodes/8176/9 "2020-07-11T04:18:08Z")

</div>


