我正在根据我研究的业务创建一个全能CRUD。问题是我尝试进行lighthouse docs中所示的嵌套变异 但由于{客户有很多联系人,而联系人有很多电子邮件}
我在schema.graphql中执行以下操作:
type Mutation {
createClient (input: createClientInput! @spread): Client @create
}
input createClientInput {
name: String!
address: String!
NIT: String
...
contracts: CreateContactsRelation
}
input CreateContactsRelation {
create: [CreateContactInput!]
}
input CreateContactInput {
name: String
position: String
emails: CreateEmailRelation # this does'n work
}
input CreateEmailRelation {
create: [CreateEmailInput!]
}
input CreateEmailInput {
email: String!
}
运行突变
mutation{
crearCliente(input: {
nombre: "prueba graphql crear 4"
direccion: "prueba"
NIT: "3225"
abreviatura: "asas"
OSDE: "prub"
organismo: "asas"
observaciones: "con contacto"
contactos: {
create: [
{
nombre: "periqito peres"
cargo: "director"
correos: {
create: [
{
email: "perez@gmail.com"
}
{
email: "perez@enet.cu"
}
]
}
}
{
nombre: "joaqin gomez"
cargo: "contador"
correos: {
create: [
{
email: "joaqin@gmail.com"
}
{
email: "joaqin@enet.cu"
}
]
}
}
]
}
}){
id
nombre
contactos{
id
nombre
cargo
correos{
id
email
}
}
}
}
输出为
{
"data": {
"crearCliente": {
"id": "53",
"nombre": "prueba graphql crear 4",
"contactos": [
{
"id": "46",
"nombre": "periqito peres",
"cargo": "director",
"correos": [] <--------------not email
},
{
"id": "47",
"nombre": "joaqin gomez",
"cargo": "contador",
"correos": [] <--------------not email
}
]
}
}
}
如您所见,未创建电子邮件。有人知道如何解决吗?