graphback
graphback copied to clipboard
Creating 1:1 relationships in Graphback
The only way to make a @oneToOne
field truly 1:1 is by also adding @unique
.
"""@model"""
type User {
id: ID
name: String
"""
@oneToOne
@unique
"""
note: Note
}
Otherwise it is identical to a 1:M/M:1 relationship and is not restricted.
I see this as a bug. It would seem strange to have to add @unique
aswell, as you would expect the @oneToOne
annotation to handle this.
If it is a docs issue, cc @machi1990 as you are working on migrations docs right now.
No strong opinion but seems like code
issue. Let's triage this
I see this as a bug. It would seem strange to have to add
@unique
aswell, as you would expect the@oneToOne
annotation to handle this.
With Relational databases, GraphQL Migrations can take care of this.
I wonder how can have something similar for MongoDB without having to track relationships on code.