【发布时间】:2020-11-18 08:59:19
【问题描述】:
大家好,这里是我的场景;
model User {
id Int @default(autoincrement()) @id
...
posts Post[]
comments Comment[]
}
model Post {
id Int @default(autoincrement()) @id
comments Comment[]
...
}
model Comment {
id Int @default(autoincrement()) @id
post Post @relation(fields: [postId], references: [id])
postId Int
...
}
所以我正在尝试删除评论,下面是我的方法
export const deleteComment = mutationField('deleteComment', {
type: 'Comment',
args: {
where: 'CommentWhereUniqueInput',
},
resolve: async (_, { where }, ctx) => {
let comment = await ctx.prisma.comment.delete({
where: where,
include:{
author: true,
post:true
},
})
return comment
},
})
但我收到一条错误消息,上面写着“不能为不可为空的字段 Comment.post 返回 null。” 知道我该如何解决吗? 谢谢
【问题讨论】:
标签: prisma-graphql nexus-prisma prisma2