我正在关注https://www.howtographql.com/graphql-python/4-authentication/上的graphql-python教程。但是,我收到3个错误提示:“无法查询类型为\”CreateUser\“的字段\"id\”。“我基本上复制了本教程中的所有源代码,并在发布之前仔细检查了我的Python代码。我使用了相同版本的Django,Graphene和其他软件包。我使用Windows10和Python3.7。如何传递错误?
突变:
mutation {
createUser (
username: "abc",
email: "abc@example.com",
password: "123456"
){
id
username
password
}
}
响应:
{
"errors": [
{
"message": "Cannot query field \"id\" on type \"CreateUser\".",
"locations": [
{
"line": 7,
"column": 5
}
]
},
{
"message": "Cannot query field \"username\" on type \"CreateUser\". Did you mean \"user\"?",
"locations": [
{
"line": 8,
"column": 5
}
]
},
{
"message": "Cannot query field \"password\" on type \"CreateUser\".",
"locations": [
{
"line": 9,
"column": 5
}
]
}
]
}
发布于 2019-05-28 23:49:26
您的查询中缺少一个级别:
mutation {
createUser (
username: "abc",
email: "abc@example.com",
password: "123456"
){
user {
id
username
password
}
}
}
https://stackoverflow.com/questions/56345757
复制相似问题