-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Me and another member of the dgraph forum have been going back and forth on how exactly this should be done. Feel free to read
The solution proposed by bennyrio (the person I've been talking to in the forum) was elaborated on after creating this. I do not want to misrepresent his view on this so below is a direct link to his explanation:
The essence of my request is that I think we should change the schema so that uid associations are capable of being defined as 1 to 1. Unfortunately, my proposal will be a breaking change, but I think it will make uid predicates consistent with the other predicate types.
Currently a schema of this:
a: uid .
b: [string] .
c: int .
Exhibits these behaviors:
a is capable of returning 0 or more nodes
b is capable of returning 0 or more strings
c is capable of returning 0 or 1 integers
My proposal would look like this:
a: uid .
b: [string] .
c: int .
d: [uid] .
Exhibiting these behaviors:
a is capable of returning 0 or 1 nodes
b is capable of returning 0 or more strings
c is capable of returning 0 or 1 integers
d is capable of returning 0 or more nodes
This would also require that any mutation which would violate this 1 to 1 association should abort with an error.
This would also mean that existing schemas would have to be updated, but I believe this will make for consistency across all predicates types when defining a list vs a single item.