这是indexloc提供的服务,不要输入任何密码
Skip to content

There can be only one variable named \"$hasura_json_var_1\ #7170

@jemink

Description

@jemink

I upgraded my hasura on below version
hasura/graphql-engine:v2.0.0-beta.2.cli-migrations-v3

And run below query

mutation updateLocation(
  $id: Int!
  $employees: [EmployeeType]
  $badges: [BadgeType]
) {
  updateLocation(
    id: $id
    employees: $employees
    badges: $badges
  ) {
    affected_row
  }
}

Variable:-

{
"badges": [],
"employees": [],
"id": 8157
}

Then I am getting below error

{
  "data": null,
  "errors": [
    {
      "originalError": {},
      "name": "GraphQLError",
      "positions": [
        96,
        149
      ],
      "source": {
        "body": [
          "mutation ($hasura_json_var_1: [EmployeeType],$hasura_json_var_1: [BadgeType],$id: Int!) { updateLocation(badges: $hasura_json_var_1,id: $id, employees: $hasura_json_var_1) { affected_row  } }"
        ],
        "locationOffset": {
          "line": 1,
          "column": 1
        },
        "name": "GraphQL request"
      },
      "message": "There can be only one variable named \"$hasura_json_var_1\".",
      "nodes": [
        {
          "kind": "Name",
          "value": "hasura_json_var_1",
          "loc": {
            "start": 96,
            "end": 113
          }
        },
        {
          "kind": "Name",
          "value": "hasura_json_var_1",
          "loc": {
            "start": 149,
            "end": 166
          }
        }
      ],
      "stack": [
        "GraphQLError: There can be only one variable named \"$hasura_json_var_1\".",
        "    at Object.VariableDefinition (/usr/app/node_modules/graphql/validation/rules/UniqueVariableNamesRule.js:25:29)",
        "    at Object.enter (/usr/app/node_modules/graphql/language/visitor.js:323:29)",
        "    at Object.enter (/usr/app/node_modules/graphql/utilities/TypeInfo.js:370:25)",
        "    at visit (/usr/app/node_modules/graphql/language/visitor.js:243:26)",
        "    at validate (/usr/app/node_modules/graphql/validation/validate.js:69:24)",
        "    at Object.validateDocument (/usr/app/node_modules/graphql-helix/dist/process-request.js:21:30)",
        "    at /usr/app/node_modules/graphql-helix/dist/process-request.js:58:21",
        "    at Object.processRequest (/usr/app/node_modules/graphql-helix/dist/process-request.js:220:7)",
        "    at /usr/app/node_modules/@graphql-mesh/cli/bin.js:426:47",
        "    at processTicksAndRejections (node:internal/process/task_queues:96:5)"
      ],
      "locations": [
        {
          "line": 1,
          "column": 97
        },
        {
          "line": 1,
          "column": 150
        }
      ]
    },
    {
      "originalError": {},
      "name": "GraphQLError",
      "positions": [
        148,
        817
      ],
      "source": {
        "body": [
          "mutation ($hasura_json_var_1: [EmployeeType],$hasura_json_var_1: [BadgeType],$id: Int!) { updateLocation(badges: $hasura_json_var_1,id: $id,employees: $hasura_json_var_1) { affected_row  } }"
        ],
        "locationOffset": {
          "line": 1,
          "column": 1
        },
        "name": "GraphQL request"
      },
      "message": "Variable \"$hasura_json_var_1\" of type \"[BadgeType]\" used in position expecting type \"[EmployeeType]\".",
      "nodes": [
        {
          "directives": [],
          "kind": "VariableDefinition",
          "variable": {
            "kind": "Variable",
            "name": {
              "kind": "Name",
              "value": "hasura_json_var_1",
              "loc": {
                "start": 149,
                "end": 166
              }
            },
            "loc": {
              "start": 148,
              "end": 166
            }
          },
          "loc": {
            "start": 148,
            "end": 179
          },
          "type": {
            "kind": "ListType",
            "loc": {
              "start": 168,
              "end": 179
            },
            "type": {
              "kind": "NamedType",
              "name": {
                "kind": "Name",
                "value": "BadgeType",
                "loc": {
                  "start": 169,
                  "end": 178
                }
              },
              "loc": {
                "start": 169,
                "end": 178
              }
            }
          }
        },
        {
          "kind": "Variable",
          "name": {
            "kind": "Name",
            "value": "hasura_json_var_1",
            "loc": {
              "start": 818,
              "end": 835
            }
          },
          "loc": {
            "start": 817,
            "end": 835
          }
        }
      ],
      "stack": [
        "GraphQLError: Variable \"$hasura_json_var_1\" of type \"[BadgeType]\" used in position expecting type \"[EmployeeType]\".",
        "    at Object.leave (/usr/app/node_modules/graphql/validation/rules/VariablesInAllowedPositionRule.js:55:35)",
        "    at Object.leave (/usr/app/node_modules/graphql/language/visitor.js:344:29)",
        "    at Object.leave (/usr/app/node_modules/graphql/utilities/TypeInfo.js:390:21)",
        "    at visit (/usr/app/node_modules/graphql/language/visitor.js:243:26)",
        "    at validate (/usr/app/node_modules/graphql/validation/validate.js:69:24)",
        "    at Object.validateDocument (/usr/app/node_modules/graphql-helix/dist/process-request.js:21:30)",
        "    at /usr/app/node_modules/graphql-helix/dist/process-request.js:58:21",
        "    at Object.processRequest (/usr/app/node_modules/graphql-helix/dist/process-request.js:220:7)",
        "    at /usr/app/node_modules/@graphql-mesh/cli/bin.js:426:47",
        "    at processTicksAndRejections (node:internal/process/task_queues:96:5)"
      ],
      "locations": [
        {
          "line": 1,
          "column": 149
        },
        {
          "line": 1,
          "column": 818
        }
      ]
    }
  ]
}

But it is working fine with alpha 10

hasura/graphql-engine:v2.0.0-alpha.10.cli-migrations-v3

Metadata

Metadata

Assignees

Labels

k/bugSomething isn't workingp/urgentImmediate action required

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions