Graphback: Creating 1:1 relationships in Graphback

Created on 7 Jul 2020  路  3Comments  路  Source: aerogear/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.

bug

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings