我是 GraphQL 的新手(仅学习了2天),并且正在构建具有CRUD功能的图书索引并尝试实现Delete部分。但是我无法解决此错误:
“ BookWhereUniqueInput类型的变量'$ where'期望值!”但 得到:{\“ where \”:{}}。原因:“ where”字段在“ where”中未定义 输入类型”。
我已经尝试了大约3个小时,并且尝试了我认为是GQL游乐场中所有突变的组合,但是没有一个对我有用。任何解决此问题的想法将不胜感激,如果您需要更多信息,请询问。
Mutation.js:
function deleteBook(parent, args, context, info) {
return context.prisma.deleteBook({ where: { id: args.id } });
}
Schema.graphQL
deleteBook(where: BookWhereUniqueInput!): Book
input BookWhereUniqueInput {
id: ID
}
type Book {
id: ID!
title: String!
authors: String!
summary: String!
releaseDate: String!
image: String!
url: String!
addedBy: User
votes: [Vote!]!
}
GraphQL Playgound:
mutation deleteBook($BookWhereUniqueInput: BookWhereUniqueInput!){
deleteBook(where: $BookWhereUniqueInput) {
title
}
}
Variables:
{
"BookWhereUniqueInput": {"id": "ck4fvz1nsnyt10993aumjalod"}
}