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

Add relationships to schema generated by CLI. #872

Open
wtrocki opened this issue Sep 30, 2020 · 6 comments
Open

Add relationships to schema generated by CLI. #872

wtrocki opened this issue Sep 30, 2020 · 6 comments
Milestone

Comments

@wtrocki
Copy link
Contributor

wtrocki commented Sep 30, 2020

Feature Request

Add relationships to models when generating them in the cli.

@kingsleyzissou
Copy link
Contributor

So just some clarification on this, if we have a model that looks something like this:

"""
@model
@datasync
"""
type Task {
  _id: GraphbackObjectID!
  title: String!
  description: String!
  status: TaskStatus
  type: String
  priority: Int
  public: Boolean
  startDate: GraphbackDateTime
  payload: GraphbackJSON

  """
  @oneToMany(field: 'note')
  """
  comments: [Comment]!
}

We want the schema to look somthing like this after using the cli:

"Comment": {
    ...
    "properties": {
       ...
       "noteId": {
        "type": "string",
        "key": "noteId",
        "isRequired": false,
        "relationship": "Task" // do we want to add this kind of field in the schema?
      },
    }

@kingsleyzissou
Copy link
Contributor

cc @wtrocki

@wtrocki
Copy link
Contributor Author

wtrocki commented Oct 12, 2020

"relationship": "Task"

  • We need relationship (actual FK from db) to exist in the local database
  • We need to be able to filter by this value (get all comments that are for this task)
  • We need to be able to subscribe and get delta for this value (it should not change but yeah)
  • We need to be able to swap ID for this relationship if the object was created using client-side ID.

We need this field in schema. We need it in types etc.

@kingsleyzissou
Copy link
Contributor

Cool thanks for clearing that up, that definitely makes sense. Just trying to get an idea of what the target schema will look like so we can work towards that

@kingsleyzissou
Copy link
Contributor

@wtrocki I actually think a made a bit of progress on this this evening. It's still a little bit tricky, but I think we can extract most of this information out of what is already there and add it to the final schema.

Do we want this to be bi-directional? So do we want a field on the task for comments with the relationship type and foreign key too? Or is it enough for it just to exist on the comment side for example?

@kingsleyzissou
Copy link
Contributor

This is still not working as expected, added to the MVP for the demo.

@kingsleyzissou kingsleyzissou added this to the Demo MVP milestone Nov 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants