【发布时间】:2018-07-13 19:51:45
【问题描述】:
我的架构如下:
type Artist @model {
id: ID! @isUnique
createdAt: DateTime!
updatedAt: DateTime!
name: String! @isUnique
songkickId: String
shows: [Show!]! @relation(name: "ArtistShow")
}
type Show @model {
id: ID! @isUnique
createdAt: DateTime!
updatedAt: DateTime!
name: String
songkickId: String
date: DateTime!
soldOut: Boolean!
pit: Boolean!
ages: String!
price: String!
multiDay: Boolean!
artists: [Artist!]! @relation(name: "ArtistShow")
venue: Venue! @relation(name: "ShowVenue")
}
type Venue @model {
id: ID! @isUnique
createdAt: DateTime!
updatedAt: DateTime!
name: String! @isUnique
address: String
latitude: Float
longitude: Float
metro: String
songkickId: String @isUnique
shows: [Show!]! @relation(name: "ShowVenue")
}
我已经编写了突变,给定 JSON 数据,创建 Artists 和 Venues 并将它们返回给我。
当时我想创建一个Show,我有:
-
ArtistID 数组 -
Venue的 ID - 填充其余
Show数据所需的所有信息(在名为showInfo的对象中)
我有一个看起来像这样的突变:
mutation: gql`
mutation {
createShow(
date: "${showInfo.date}"
soldOut: ${showInfo.soldOut}
pit: ${showInfo.pit}
ages: "${showInfo.ages}"
price: "${showInfo.price}"
multiDay: ${showInfo.multiDay}
) {
id
}
}
`,
如何编辑它,以便在我正在创建的 Show 和适当的 Venue 和 Artist ID 之间创建关系?
【问题讨论】: