[英]typegraphql : parameter error in playground when using variables
I'm facing a weird issue, when trying to execute mutations with variables as parameters in the graphql playground 当尝试在graphql游乐场中使用变量作为参数执行突变时,我面临一个奇怪的问题
mutation userLogin($username:String!, $password:String!){
userLogin(
username: $username
password: $password)
{
id
}
}
Parameters in playground "QUERY VARIABLES" tab: 游乐场“ QUERY VARIABLES”选项卡中的参数:
{
"username": "test@test.com"
"password": "Test"
}
this failed with message 这失败并显示消息
{
"path": "unk",
"code": "INTERNAL_SERVER_ERROR",
"message": "Variable \"$username\" of required type \"String!\" was not provided."
},
{
"path": "unk",
"code": "INTERNAL_SERVER_ERROR",
"message": "Variable \"$password\" of required type \"String!\" was not provided."
}
but running this is working well : 但是运行它运行良好:
mutation {
userLogin(
username: "test8@test.com"
password: "Test1234!")
{
id
}
}
What am I missing here ? 我在这里想念什么?
the variables are @ArgsType 变量是@ArgsType
@ArgsType()
export class LoginInputType {
@Field()
username: string;
@Field()
password: string;
}
and I declare them in resolver 我在解析器中声明它们
async userLogin(
@Args() { username, password }: LoginInputType,
@Ctx() context: GlobalContext
): Promise<UsersEntity | null> {
Incorrectly formatting your variables inside Playground will cause it to just not send the variables. 在Playground中错误格式化变量的格式将导致它不发送变量。 If any of the variables were non-null, your request will fail validation. 如果任何变量都不为空,则您的请求将无法通过验证。
This 这个
{
"username": "test@test.com"
"password": "Test"
}
is not valid JSON because it's missing a comma. 无效的JSON,因为它缺少逗号。 Playground will shown a red error indicator to the left of any lines that have syntax errors like these. Playground会在任何具有此类语法错误的行的左侧显示一个红色错误指示符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.