# Representation of dgraph.type with dgraph4j

**URL:** <https://discuss.dgraph.io/t/representation-of-dgraph-type-with-dgraph4j/5473>\
**Category:** Dgraph\
**Tags:** mutation, java-client\
**Created:** [November 20, 2019, 7:46am UTC](https://discuss.dgraph.io/t/representation-of-dgraph-type-with-dgraph4j/5473 "2019-11-20T07:46:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shivangi1015](https://avatars.discourse-cdn.com/v4/letter/s/9e8a1a/32.png) [@shivangi1015](https://discuss.dgraph.io/u/shivangi1015)\
**Post date:** [November 20, 2019, 7:46am UTC](https://discuss.dgraph.io/t/representation-of-dgraph-type-with-dgraph4j/5473/1 "2019-11-20T07:46:00Z")

</div>

How can we add type to a node while storing it in dgraph with dgraph4j client?

In the code, while adding a node, where we are converting object to JSON and using setSetJson method of Mutation class to add data to dgraph.

```auto
private boolean setData(final String personJson) {
          
        Mutation mutation = Mutation.newBuilder()
                .setSetJson(ByteString.copyFromUtf8(personJson))
                .build();

        try (Transaction txn = clients.newTransaction()) {
            txn.mutate(mutation);
            txn.commit();
            return true;
        }
    }

```

when using setSetJson method, it is not able to add dgraph.type to the node.  
So, is there any way to add type to the node?

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [November 20, 2019, 2:23pm UTC](https://discuss.dgraph.io/t/representation-of-dgraph-type-with-dgraph4j/5473/2 "2019-11-20T14:23:29Z")

</div>

You can make a second mutation after you have inserted JSON. Just take the mutation mapped UID and make a new mutation by adding dgraph.type.

Another way you can do it is by using Bulk Upsert.

```auto

upsert {
  query {
    v as var(func: has(email)) #just an example, you should add a contextual query here.
  }

  mutation {
    set {
      uid(v) <dgraph.type> "User" .
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![shivangi1015](https://avatars.discourse-cdn.com/v4/letter/s/9e8a1a/32.png) [@shivangi1015](https://discuss.dgraph.io/u/shivangi1015)\
**Post date:** [November 21, 2019, 6:38am UTC](https://discuss.dgraph.io/t/representation-of-dgraph-type-with-dgraph4j/5473/3 "2019-11-21T06:38:20Z")

</div>

Is there any way to add type information to the node while it is being created?

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [November 21, 2019, 3:37pm UTC](https://discuss.dgraph.io/t/representation-of-dgraph-type-with-dgraph4j/5473/4 "2019-11-21T15:37:21Z")

</div>

In the body of the mutation.
