且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用grapiql的GraphQl变量 - 变量未定义

更新时间:2022-04-25 10:04:44

在操作中使用的任何变量都必须声明为操作定义的一部分,如下所示:

Any variables used inside an operation must be declared as part of the operation definition, like this:

query OptionalButRecommendedQueryName ($var1: String) {
  getItem(dictionaryType: $var1) {
    code
    name
    description
  }
}

这允许 GraphQL 根据提供的类型验证您的变量,并验证是否正在使用变量代替正确的输入.

This allows GraphQL to validate your variables against the provided type, and also validate that the variables are being used in place of the right inputs.