dgraph icon indicating copy to clipboard operation
dgraph copied to clipboard

[ENHANCEMENT]: add @unique constraint in GraphQL Schema

Open rderbier opened this issue 1 year ago • 0 comments

Use case and current behavior

GraphQL schema has @id but not unique constraint.

Enhancement

add @unique directive at field level. From : https://github.com/dgraph-io/dgraph/issues/8179


Multiple Uniques or @unique

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

That would be the equivalent of SQL

ADD CONSTRAINT UNIQUE (username)
ADD CONSTRAINT UNIQUE (email)

rderbier avatar Jun 09 '23 18:06 rderbier