Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Implicit relationships #936

Open
lastmjs opened this issue Mar 18, 2020 · 4 comments
Open

Implicit relationships #936

lastmjs opened this issue Mar 18, 2020 · 4 comments

Comments

@lastmjs
Copy link

lastmjs commented Mar 18, 2020

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.

@craicoverflow
Copy link

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.

@lastmjs
Copy link
Author

lastmjs commented Mar 19, 2020

Excellent news! Keep up the good work

@lastmjs
Copy link
Author

lastmjs commented Jul 28, 2020

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

@wtrocki
Copy link
Contributor

wtrocki commented Jul 29, 2020

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants