Using more than 2 environments

is it possible to use more than two environments (production and staging) in Retool? For our use case we need to have at least 3 environments - the apps will be the same and the queries will have different connection details. Is that possible to do while keeping the apps synchronized across environments?

Hi @olexlyap!

This is actually a pretty common feature request (see other Community post here), and we'll keep that forum post up to date, so it would be awesome if you could add your plus one. In the meantime, I have a hacky workaround 😬

You could use a JS query to trigger which query (you'd need one for each resource) is run based on a dropdown or button group (where you could choose the resource type). That way you could switch between staging/prod/another env/etc in one app!

In a JS query, you can use that dropdown's value to determine the query you'd like to run! You'd just need to create 3 (or more, depending on your number of environments) different queries, 1 for each resource type.

Your JS query could look something like:

if (select1.value == "production") {
} else if (select1.value == "staging") {
} else if (select1.value == "dev") {

So the only duplicate work would be having three of the "same" queries (with the different resource correctly chosen) within the same app.

Let me know if that helps at all or if you have any other questions!

Thank you, @victoria!

I agree the workaround you suggested is quite hacky and has issues with code duplication and having too many queries per app, but if that's the only way to go for now, then we could try building something based on it. It is definitely not the worst option, and your advice was helpful :slightly_smiling_face:

1 Like

"Definitely not the worst option" made me laugh :sweat_smile: Hopefully we have a better option for multiple environments soon!

I agree. I would go farther and say they should be permissioned as well, where certain users can only see some environments (end users only see prod - so they cannot accidentally toggle on staging on accident), and new hires start with just qa and dev.

Here's a quick mockup that I was thinking about.

Screen Shot 2021-05-03 at 2.20.58 PM

Absolutely! As another hopefully not the worst option, you can use the {{current_user.groups}} object (visible in the bottom of the left panel) to only show certain values in the dropdown.
The dropdown's value field would reference a transformer that checks current_user.groups and returns an array of environments that they'll have access to.
In my example, you could access my permission group with {{current_user.groups[0].name}} :blush: