This is a strange one: if you reference a temporary state variable in a graphql query transformer, it works fine...unless you attempt to also reference the results data in the transformer. And we have many use cases where we need to do both
To try and simplify as much as possible: an app with two queries
Query 1 - Javascript
const str = 'State: ';
await ts.setValue(str);
Event handler = query trigger 2
Also checked "Keep variable references inside ..."
Query 2 - GraphQL
https://countries.trevorblades.com/
query GetBrazil {
country(code: "BR") {
name
states {
name
}
}
}
Hi @aviator22, Thanks for the helpful walkthrough! Can you also share a screenshot of the Query 2 response without the transformer? (from the left panel)
If you comment out the line const stringpart1 = {{ts.value}}; ....you still get this error
If you delete that line (and replace it with a benign const stringpart1 = 'test'; .....no error occurs
Conclusion
If a variable is referenced{{ }} -- even in a comment -- in this specific part of a transformer, something funky is happening. Retool seems to try and run/evaluate the transformer before the query itself even runs.
You can validate that conclusion I made by running a transformer with and without a variable in it. And as I noted above the variable doesn't need to be in the forEach, it can even be in a // comment. If a variable exists, you'll get this behavior.