为什么我在过滤器中使用枚举时会在 graphql 中出现语法错误?

Why I get syntax error in graphql when I use enum in filter?

每个用户都有性别属性。性别 属性 在 graphql 中是枚举。

我想查询所有只有 femalemale 值的用户。

为什么 I write my query on graphql playground 我收到错误消息?

我也尝试写:userMany(filter: { gender: [female, male] }) {但是语法错误。

是否有另一种方法来编写此查询以获得结果?

查询:

{
  userMany(filter: { gender: female AND male }) {
    name
    age
    gender
    someMixed
    salaryDecimal
    virtualField
  }
}

错误:

{
  "errors": [
    {
      "message": "Syntax Error: Expected :, found Name \"male\"",
      "stack": [
        "Syntax Error: Expected :, found Name \"male\"",
        "",
        "GraphQL request:2:41",
        "1 | {",
        "2 |   userMany(filter: { gender: female AND male }) {",
        "  |                                         ^",
        "3 |     name",
        "    at syntaxError (/app/node_modules/graphql/error/syntaxError.js:15:10)",
        "    at expectToken (/app/node_modules/graphql/language/parser.js:1428:38)",
        "    at parseObjectField (/app/node_modules/graphql/language/parser.js:588:3)",
        "    at item (/app/node_modules/graphql/language/parser.js:571:12)",
        "    at any (/app/node_modules/graphql/language/parser.js:1500:16)",
        "    at parseObject (/app/node_modules/graphql/language/parser.js:576:13)",
        "    at parseValueLiteral (/app/node_modules/graphql/language/parser.js:470:14)",
        "    at parseArgument (/app/node_modules/graphql/language/parser.js:348:12)",
        "    at many (/app/node_modules/graphql/language/parser.js:1515:16)",
        "    at parseArguments (/app/node_modules/graphql/language/parser.js:334:54)",
        "    at parseField (/app/node_modules/graphql/language/parser.js:321:16)",
        "    at parseSelection (/app/node_modules/graphql/language/parser.js:295:76)",
        "    at many (/app/node_modules/graphql/language/parser.js:1515:16)",
        "    at parseSelectionSet (/app/node_modules/graphql/language/parser.js:282:17)",
        "    at parseOperationDefinition (/app/node_modules/graphql/language/parser.js:192:21)",
        "    at parseExecutableDefinition (/app/node_modules/graphql/language/parser.js:169:12)"
      ]
    }
  ]
}

试试这个:

{
  userMany(filter: {OR: [{gender: female}, {gender: male}]}) {
    name
    age
    gender
    someMixed
    salaryDecimal
    virtualField
  }
}