ProjectionsSchemaObject
@unique
You can mark field compounds as unique by using the @unique directive.
This directive exists on field level as well: @unique
Example of One Unique Field Compound
type User
@upsertOn(...)
@unique(fields: ["name", "email"], name: "name and email unique") {
name: String!
email: String!
}In this example the combination of name and email has to be unique.
A violation will result in the message violation of unique constraint 'name and email unique'.
Example of Multiple Unique Field Compounds
The @unique directive can also be specified more than once to define multiple unique field compounds.
type User
@upsertOn(...)
@unique(fields: ["name", "email"], name: "name and email unique")
@unique(fields: ["name", "address"], name: "name and address unique") {
name: String!
email: String!
address: String!
}In this example both the combination of name and email and the combination of name and address have to be unique.