こんにちは皆さん、これが私が持っているシナリオです。
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
},
})
しかし、「null 非許容フィールド Comment.post に対して null を返すことはできません」というエラー メッセージが表示されます。どうすれば解決できますか?ありがとう