loopback-graphql icon indicating copy to clipboard operation
loopback-graphql copied to clipboard

Support relation of "through model"

Open JonnyBGod opened this issue 9 years ago • 1 comments

Just a placeholder for tracking since it is difficult to track from project.

JonnyBGod avatar Dec 02 '16 23:12 JonnyBGod

@JonnyBGod, @Tallyb, just to be sure, currently, attempting to query a relation with this structure is unsupported? I guess I should also ask--is this package being supported any longer? Seems to have been abandoned.

graphQL

{
  user(id: "59e943fe9c2121128398230b") {
    roles {
      totalCount
      roles {
        id
        name
      }
    }
  } 
}

user.json

...
  "relations": {
    "roles": {
      "type": "hasMany",
      "model": "role",
      "through": "userRole",
      "foreignKey": "userId"
    }
  },

...

role.json

...
  "relations": {
    "users": {
      "type": "hasMany",
      "model": "user",
      "through": "userRole",
      "foreignKey": "roleId"
    }
  },
...

user-role.json

...
  "relations": {
    "roles": {
      "type": "belongsTo",
      "model": "role",
      "foreignKey": "roleId"
    },
    "users": {
      "type": "belongsTo",
      "model": "user",
      "foreignKey": "userId"
    }
  },
...

MichaelPlaxico avatar Oct 25 '17 21:10 MichaelPlaxico