使用带有输入变量的GraphiQL UI时Graphql强制检查不起作用

时间:2018-10-10 09:48:07

标签: graphql graphql-java github-graphql

我已经定义了如下所示的变体,其中电子邮件字段标记为必填

type Mutation {
    bookTicket (person: PersonInput! ,email: String!): Ticket
}

input PersonInput{
    personId: ID!
    name: String!
    date: String!
    comment: String
}

当我尝试通过GraphIQl UI执行变异而没有传递电子邮件字段时,UI不会引发验证错误,并且使用电子邮件字段的空值调用端点。

mutation($personInput:PersonInput!, $email :String!){
    bookTicket(person:$personInput,email: $email){
        id
    }
}


Variables
{
    "personInput": {
        "personId": "111",
        "name": "test",
        "date": "10-Oct-2018",
        "comment": "Book"
    }

}

如果我尝试使用内联变量运行突变,则验证工作正常,并显示电子邮件不能为空的异常。

 mutation{
     bookTicket(person:{personId: "111",  name: "test", date: "10-Oct- 
     2018",comment: "Book"}
     email:""){
        id
     }
 }

有人可以帮助我,为什么验证在第一种情况下不起作用?

0 个答案:

没有答案