我正在尝试使用在 GraphQL-yoga 服务器上运行的 Prisma 在 graphql 中设置 updateNode 突变。这是我尝试运行突变时收到的错误:
"变量\"$_v0_data\" 的值无效{ 数据:{ 名称:\"Test\" },其中:{ id: \"cjqulnr0yftuh0a71sdkek697\" } };字段 \"data\" 未由 CocktailUpdateInput 类型定义。 \n变量 \"$_v0_data\" 获得无效值 { data: { name: \"Test\" },其中:{ id: \"cjqulnr0yftuh0a71sdkek697\" } };字段 \"where\" 未由 CocktailUpdateInput 类型定义。 "
这是我的突变解析器:
const Mutation = {
async updateCocktail(parent, args, ctx, info) {
const data = { ...args };
delete data.id;
const where = {id: args.id};
return await ctx.db.mutation.updateCocktail({ data, where }, info);
},
}
数据模型.棱镜:
type Cocktail {
id: ID! @unique
name: String!
info: String
glass: Glass
ingredients: [Ingredient]
steps: [Step]
}
架构.graphql
type Mutation {
updateCocktail(data: CocktailUpdateInput!, where: CocktailWhereUniqueInput!): Cocktail
}
最后这是我要在操场上执行的操作:
mutation{
updateCocktail(
where: {id: "cjqulnr0y0tuh0a71sdkek697"},
data: {
name: "Test"
}
){
id
name
}
}