Description
Have you tried Dgraph before this proposal? and did not find anything similar?
No response
What you wanted to do.
From the DQL level up, there should be a way to force uniqueness. For backwards compatibility this should be easy. Adding this to a node that already has duplicate values would not be allowed.
This simplest way todo this would be to have a @unique directive in the dql schema:
type Film {
name @unique
release_date
revenue
running_time
starring
director
}
or with a composite index:
type Film @unique(name, release_date) {
name
release_date
revenue
running_time
starring
director
}
This should also be possible on a 'facet', but there would need to be a way to declare facet types in dql. Perhaps:
facet Friend {
close @unique
...
and for composite:
facet Friend @unique(close, date) {
close
date
}
Note: In GraphQL, the unique directive would need the "field" input to be not break the GraphQL spec, here we can simplify it with just an array inside ().
What you actually did.
You can create this in GraphQL, but it is not enforced once added, and DQL is certainly not enforced. Composite indexes are also currently impossible.
Why wasn't it great, with examples.
We need better data integrity.
Additional information.
It should be 100% impossible to add any kind of duplicate data once this unique directive is activated.
Unique constraints should be nullable by default, but could be not null with the @NotNull directive.
This is how @akon-dey wants to implement this. First in DQL, then GraphQL.
Related to: