Filtering using query variables

I am trying to use query variables as input to the the filters ge and I can’t seem to get it to work

Given the following query

{
  ua(func: uid(0xfb7f7)) {
    uid
    start_ua {
      sua as index
    }
    recorded_in {
      actions @filter(ge(index, sua)){
        index
      }
    }
  }
}

I get the following error

{
  "errors": [
    {
      "code": "ErrorInvalidRequest",
      "message": "Some variables are defined but not used\nDefined:[sua]\nUsed:[]\n"
    }
  ],
  "data": null
}

Can’t get what is wrong here O_o

You can’t use a variable created in the same query. You need to create another one. e.g:

{
  var(func: uid(0xfb7f7)) {
    uid
    start_ua {
      sua as index
    }
}
   myquery(func: has(recorded_in))  {
      actions @filter(ge(index, sua)){
        index
      }
    }
  
}

OR

(...)
  myquery(func: has(actions)) @filter(ge(index, sua)) {
        uid
        index
    }

OR (without using has function)

{
  ua(func: uid(0xfb7f7)) {
    uid
    start_ua {
      sua as index
    }
    REC as recorded_in 
  }

   myquery(func: uid(REC))  {
      actions @filter(ge(index, sua)){
        index
      }
    }
}