Dynamic Resource Switching in Retool

hey @leman and welcome!

looks like others this year are wanting this too:

apparently you can set the environment via _environment URL parameter for the app: Customize app URLs | Retool Docs

maybe you can have multiple queries -- one for each environment -- and conditionally trigger or reference their data in JS? as in, you could create a resource for your database (or whatever) for each environment and then do:

let data = {}
const env = retoolContext.environment

function triggerQueryGetData(query) {
    await query.trigger({additionalScope: {}})
    return query.data
}

if (env == "staging") {
    return triggerQueryGetData(queryStaging)
} else if (env == "production") {
     return triggerQueryGetData(queryProduction)
}
console.error(`no query assigned to environment "${env}"`)

it's not the most maintainable, but it sounds like retool might consider adding it soon. I know there's been a lot of discussion and requests surrounding environments this year, so I'm hopeful too.