Can Graph QL variables be used as filters with regexp

Suppose I have

{
var(func:allofterms(name@en, “angelina jolie”)) {
name@en
actor.film {
A AS performance.film {
B AS genre
}
}

I would like to do:

K @filter(regexp(K ,$B)) {
K1

K2
K3
}

but this does not work. Is there a way to do this?

See if this answer helps you:

For future reference can you wrap your code in blocks beginning the block with a new line with ``` and ending the block with a new line using ``` as it will help make it easier to read:

{
  var(func:allofterms(name@en, “angelina jolie”)) {
    name@en
    actor.film {
      A AS performance.film {
        B AS genre
      }
    }

^ noticeably incomplete code

K @filter(regexp(K ,$B)) {
  K1
  K2
  K3
}

^ noticeably separate code block