graphback icon indicating copy to clipboard operation
graphback copied to clipboard

Creating 1:1 relationships in Graphback

Open craicoverflow opened this issue 4 years ago • 3 comments

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.

craicoverflow avatar Jul 07 '20 08:07 craicoverflow

If it is a docs issue, cc @machi1990 as you are working on migrations docs right now.

craicoverflow avatar Jul 07 '20 08:07 craicoverflow

No strong opinion but seems like code issue. Let's triage this

wtrocki avatar Jul 07 '20 08:07 wtrocki

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.

machi1990 avatar Aug 26 '20 08:08 machi1990