Convert string to a valid logql query?

I have on output string like “{service_name = “myservice”}”. How can I convert it to a valid logql command exactly inside place where I enter the command in the dashboard panel?

I need it to use templating opportunities LogQL template functions | Grafana Loki documentation

But unfortunately it returns just string that I can’t use as part of my logql queries with error

parse error at line 1, col 329: syntax error: unexpected STRING

That is valid logQL except the left/right quotes. Does {service_name = "myservice"}work if you use doublequotes "?

Example

of course. Also it works if I add constant variable like $additional_query to main query like:

{service_name = “myservice”} $additional_query

where $additional_query can be something like !~ “loki”

omg, I’ve just found inside docs, that I can’t use templating anywhere else except | line_format and | label_format LogQL template functions | Grafana Loki documentation

So, looks like that my initial idea of usage templates in any part of query or to generate query itself is not viable, right?

And I can’t define, for example, default value if variable not exist?