[英]graphql error: mutation with where not working
I am using Prisma GraphqQL and I got this error for a mutation with where selector: "You provided an invalid argument for the where selector on User" 我正在使用Prisma GraphqQL,我得到了一个带有选择器的变异的错误:“你为User上的where选择器提供了一个无效的参数”
Mutation: 突变:
mutation UpdateUserMutation($data: UserUpdateInput!, $where: UserWhereUniqueInput!) {
updateUser(data: $data, where: $where) {
id
name
email
role
}
}
Variables: 变量:
{
"data": {
"name": "alan", "email": "alan@gmail.com", "role": "ADMIN"
},
"where": {
"id": "cjfsvcaaf00an08162sacx43i"
}
}
Result: 结果:
{
"data": {
"updateUser": null
},
"errors": [
{
"message": "You provided an invalid argument for the where selector on User.",
"locations": [],
"path": [
"updateUser"
],
"code": 3040,
"requestId": "api:api:cjftyj8ov00gi0816o4vvgpm5"
}
]
}
Schema: 架构:
updateUser(
data: UserUpdateInput!
where: UserWhereUniqueInput!
): User
type UserWhereUniqueInput {
id: ID
resetPasswordToken: String
email: String
}
Why this mutation is not working? 为什么这个突变不起作用?
With colors: Mutation GraphQL 有颜色:Mutation GraphQL
Schema Graphql
Schema Graphql
EXTRA INFORMATION 额外的信息
Full code of this Project is here : 该项目的完整代码在这里 :
Graphql playground is here : Graphql playground在这里 :
Console view (variable are empty): 控制台视图 (变量为空):
Query for user (with id: cjfsvcaaf00an08162sacx43i). 查询用户 (id:cjfsvcaaf00an08162sacx43i)。 So user can be found with "where" operator in query, but not in mutation.
因此,用户可以在查询中找到“where”运算符,但不能在变异中找到。
Your updateUser resolver is not implemented correctly: 您的updateUser解析程序未正确实现:
async function updateUser(parent, { id, name, email, role }, ctx, info) {
// console.log( id, name, email)
await ctx.db.mutation.updateUser({
where: { id: id },
data: {name: name, email: email, role: role},
})
}
Your mutation has the two parameters data and where, but you expect the parameter list { id, name, email, role }. 您的变异具有两个参数数据和位置,但您希望参数列表{id,name,email,role}。
Either update your schema, or your resolver accordingly. 您可以相应地更新架构或解析器。
Source: https://github.com/graphcool/prisma/issues/2211 资料来源: https : //github.com/graphcool/prisma/issues/2211
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.