Support multiple unique fields in dgraph GraphQL

Hi @jdgamble555, multiple @id fields doesn’t guarantee unique constrain on a combination of two fields.
It just means that we can have multiple @id fields in a type. And every such field value will be unique across all the nodes of that type. But other @id fields or normal fields in a type can have that value. ​

Example :
type {
​t1: String @id
​t2: String @id
​t3: string
}

Below is the valid state according to @id rules but it doesn’t guarantee unique constraint on two fields.
node1:-
t1-“Alice”
t2-“Bob”

node2:-
t1-“Bob”
t2-“Alice”

We have a ticket for composite @id fields that will allow us to have a unique constraint on two or more fields and we will try to add it soon.
see this:
RFC: Allow multiple unique fields in graphql schema
Composite @id fields

2 Likes