Pass a dynamic resource via additionalScope

Hi there, should it be possible to use a variable passed to a query as additionalScope in the query resourceId selector? (using the fx toggle next to the resource in a query)

Our use-case: we have an API that we run in different cloud regions, and the endpoints in each region are behind unique hostnames. We've defined each as their own 'retool resource' and we'd like to run the same queries across them by dynamically adjusting the resource using a variable that we can pass in from upstream.

One example is rendering a list with the results of the same query executed across all N cloud region APIs we have, without having to define N queries (1 per resource). Since we're rendering a list with N items there is no single global variable that can be used in the dynamic resource block within the query, it needs to be dynamic or passed in.

Hope that makes sense, thanks!

Hey @RoshanJ, thanks for raising this!

It looks like you were already in contact with the support team and, at the moment, it isn't possible to pass a dynamic resource via additional scope. I can report back here if support is added!

In the meantime, the closest workaround would be to dynamically set a temporary state which, as you mentioned, requires the queries to be run sequentially:

const resources = [/* your resource ids */];
for(let id of resources){
   await currentResourceId.setValue(id);
   await dynamicResourceQuery.trigger();
1 Like