graphback icon indicating copy to clipboard operation
graphback copied to clipboard

Implicit relationships

Open lastmjs opened this issue 5 years ago • 4 comments

Would it be possible to implicitly identify relationships, without the extra one-to-many directive? It is a lot of boilerplate and confusing having to write that in.

Instead of this:

"""
@model
"""
type Note {
  id: ID!
  title: String!
  """
  @oneToMany field: 'note'
  """
  comments: [Comment]
}

Why not this?

"""
@model
"""
type Note {
  id: ID!
  title: String!
  comments: [Comment]
}

"""
@model
"""
type Comment {
  id: ID!
  note: Note
}

Prisma is able to identify this in most cases if I'm not mistaken. The simpler it can be the better, and having to add the extra annotations is more complicated than simply thinking in terms of graph relationships as the GraphQL SDL syntax already allows us to do.

lastmjs avatar Mar 18 '20 16:03 lastmjs

Hey @lastmjs !

Yes this would definitely be possible and it is something we want to implement soon.

We released this relationship implementation with one path/one way of doing it initially so that we could receive feedback on the general approach before refining it.

It is definitely on our backlog.

craicoverflow avatar Mar 19 '20 15:03 craicoverflow

Excellent news! Keep up the good work

lastmjs avatar Mar 19 '20 18:03 lastmjs

Is this still on the backlog? I would love to simplify and remove the relationship annotations wherever possible. The most confusing thing right now is the many-to-many relationships, and requiring an explicit join table in the schema. Prisma did this very well, essentially allowing you to create a many-to-many relationship with two array types, one on each object type. Dealing with the join table has led to unnecessary confusion on my team

lastmjs avatar Jul 28 '20 20:07 lastmjs

Added to milestone. We hoping to push 0.15.0 faster to resolve your most pressing issues. 0.16.0 will follow instantly.

wtrocki avatar Jul 29 '20 08:07 wtrocki