Support multiple unique fields in dgraph GraphQL

Moved from GitHub dgraph/5232

Posted by sessionboy:

What you wanted to do

Expect team to provide support for multiple unique fields in dgraph GraphQL, this is a very common requirement, like this:

 type User {
    id: ID!
    name: String! @unique
    username: String! @unique
    phone_number: String! @unique
    email: String @unique
    ...
 }

The unique field is allowed to be empty, and no verification is performed when the value of the unique field is empty. For example email above.

Any external references to support your case

prisma provides a great implementation for this, which can be used as a reference.

4 Likes

MichaelJCompton commented :

Hi, thanks for the suggestion.

We’ll take this onboard as we look at GraphQL features. No commitment yet on what we’ll support, but it would be great to support composite keys as well as the kind of uniqueness described here.

1 Like

sessionboy commented :

Thanks for team efforts, I look forward to it.

Any update on this?

1 Like

Hi @Wulfheart, this request is definitely in our roadmap and the team has plans to work on it. This can be seen in the docs too at the bottom of GraphQL docs. :slight_smile:

3 Likes

Hi. Nice to see this on the radar. I am interested in this as well. It would be great to have not just IDs but also composite unique constraints like unique (col1, col2) Thanks

1 Like

Is there an ETA yet?

Hi @vinniefg, thanks for showing interest in this feature.
Sorry, this won’t be part of the next 20.11 release. But this is definitely under consideration for later and maybe prioritized based on demands. I can’t give you any ETA though.
Thanks.