contains() function is way to slow! If performance is an Issue, I recommend avoiding it at all costs.
what I do, is I build entirely the “filter” piece of the code, using another chained variable that makes another query using Variable1, then with reduce function and some trickery I reduce all my “selected values” to one single string.
then in my main query I use the “filter” like this:
|> filter(fn: (r) => ${Variable2})
Note, I cannot give a general piece of code because it is kind of specific to your data set, and you may need to add some “dummy” values in case the query returns a “null” string because.
|> filter(fn: (r) => ) will get you an error
