0

我有两组具有以下架构的记录

type Player {
    id: ID! @unique
    name: String!
    links: [NPC!]! @relation(name: 'linkedNpcs')
}

type NPC {
        id: ID! @unique
        name: String!
        playerLinks: [Player!]! @relation(name: 'linkedNpcs')
}

我想向被linkedNpcs调用的relationType.

我将如何在我的types.graphql文件中写这个?每个player-npc链接都应该包含一个唯一的记录,并且由于它是多对多的关系,所以这个元数据应该存在于连接表上是有意义的。

4

1 回答 1

0

通过graphcool论坛回答:https ://www.graph.cool/forum/t/adding-a-field-to-a-relation-table-in-prisma/3086/2

谢谢@matic!

enum RelationType {
  A
  B
  C
}

type Player {
  id: ID! @unique
  name: String!
  links: [PlayerNPC!]! @relation(name: 'linkedPlayer')
}

type PlayerNPC {
  id: ID! @unique

  relationType: RelationType!

  player: Player! @relation(name: 'linkedPlayer')
  npc: NPC! @relation(name: 'linkedNPC')
}

type NPC {
  id: ID! @unique
  name: String!
  links: [PlayerNPC!]! @relation(name: ‘linkedNPC’)
}
于 2018-04-07T05:54:19.910 回答