"variable invitationId of type Int! is used in position expecting Int_comparison_exp"

Viewed 1195

I was trying following query on hasura platform and it gave below error. I got solution for the same. That's why I'm sharing. variables:

     {
          "invaId": 791
       }


Query:


    mutation UpdateQuery($status:String!,$invaId:Int!) {
      update_inva(_set: {status: $status},where:{id:$invaId}){
         affected_rows
      }
    }


Output:
{
  "errors": [
    {
      "extensions": {
        "path": "$.selectionSet.update_inva.args.where.id",
        "code": "validation-failed"
      },
      "message": "variable invaId of type Int! is used in position expecting Int_comparison_exp"
    }
  ]
}

I faced this error after passing the variable of type Int!.

1 Answers

The problem is in query.

Look at the where clause

where:{id:$invitationId})

where clause expects the comparison type too for eg. _eq.

That was the exact thing which I was missing.

So, I updated the query as below, and things were running perfectly

Query:

mutation UpdateQuery($status:String!,$invaId:Int!) {
  update_inva(_set: {status: $status},where:{id:{_eq:$invaId}}){
    affected_rows
  }
}
Related