# Generate IDs on the client

**URL:** <https://discuss.dgraph.io/t/generate-ids-on-the-client/11006>\
**Category:** GraphQL\
**Tags:** kind:question\
**Created:** [October 17, 2020, 11:14pm UTC](https://discuss.dgraph.io/t/generate-ids-on-the-client/11006 "2020-10-17T23:14:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sydney-o9](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/sydney-o9/32/2378_2.png) [@Sydney-o9](https://discuss.dgraph.io/u/Sydney-o9)\
**Post date:** [October 17, 2020, 11:14pm UTC](https://discuss.dgraph.io/t/generate-ids-on-the-client/11006/1 "2020-10-17T23:14:52Z")

</div>

I’m using Slash GraphQL and am considering generating IDs on the client.

[https://dgraph.io/docs/graphql/schema/ids/](https://dgraph.io/docs/graphql/schema/ids/)

Is it possible to generate IDs on the client for GraphQL / Dgraph and if so could you just point me in the direction to be able to generate a unique ID and send it to Slash GraphQL?

Thank you!

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [October 17, 2020, 11:20pm UTC](https://discuss.dgraph.io/t/generate-ids-on-the-client/11006/2 "2020-10-17T23:20:55Z")

</div>

You can used the @id directive to assign strings as ID. So process would be on the client side use something like uuid to generate unique keys and then use them in mutations when adding new data.

---

<div class="post-metadata">

**Author:** ![Sydney-o9](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/sydney-o9/32/2378_2.png) [@Sydney-o9](https://discuss.dgraph.io/u/Sydney-o9)\
**Post date:** [October 17, 2020, 11:27pm UTC](https://discuss.dgraph.io/t/generate-ids-on-the-client/11006/3 "2020-10-17T23:27:01Z")

</div>

> [@amaster507](#):
>
> ID

This means 2x unique fields: ID and UUID. Can we just generate a unique 64 bit identifier the same way Dgraph does for the ID so there is only 1 unique identifier?

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [October 18, 2020, 1:49am UTC](https://discuss.dgraph.io/t/generate-ids-on-the-client/11006/4 "2020-10-18T01:49:00Z")

</div>

Not to my knowledge. From my understanding zero server is responsible for generating these IDs and has a process to reserve a bulk set and then release the ones not used.

---

<div class="post-metadata">

**Author:** ![Sydney-o9](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/sydney-o9/32/2378_2.png) [@Sydney-o9](https://discuss.dgraph.io/u/Sydney-o9)\
**Post date:** [October 18, 2020, 1:58am UTC](https://discuss.dgraph.io/t/generate-ids-on-the-client/11006/5 "2020-10-18T01:58:51Z")

</div>

Right ok - thank you @amaster507 very helpful, so I would create a second unique id which I would use as the source of truth for the client and disregard Dgraph self-generated ID all-together apart from dealing with associations I guess.

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [October 18, 2020, 2:38am UTC](https://discuss.dgraph.io/t/generate-ids-on-the-client/11006/6 "2020-10-18T02:38:59Z")

</div>

If you use the @id then you can use your custom id for linking relationships too. The dgraph uid would not be available then on the graphql endpoint, but it does still exist in the underlying DQL

---

<div class="post-metadata">

**Author:** ![Sydney-o9](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/sydney-o9/32/2378_2.png) [@Sydney-o9](https://discuss.dgraph.io/u/Sydney-o9)\
**Post date:** [October 18, 2020, 2:55am UTC](https://discuss.dgraph.io/t/generate-ids-on-the-client/11006/7 "2020-10-18T02:55:08Z")

</div>

Amazing, I didn’t think of that either. A big thank you @amaster507 🙏
