Run queries in parallel in JS code

Hi guys, I have a Javascript query that makes 12 requests to an API which are not dependent on each other, so I could execute them in parallel. Currently, they run sequentially as follows

    additionalScope: {
        cutoffDate: data
    onSuccess: function (response) {
        // some code
        runQuery(i + 1);

is there a way to run the queries in parallel? Thank you

I know how to run them all in parallel in JS, but I think that retool has a limitation ( I have to open a question about that) that doesn't allow to run the queries in parallel because they overwrite each other parameters.

Hey Danielo,

You should be able to construct an array of promises to call, then use Promise.all to fire the queries concurrently. For example:

let arr = [1,2,3,4,5]

return Promise.all(>{
return query2.trigger({
additionalScope: {
id: t

Mark, I am more than aware of how to do this on JS.
However, as I said, a bug on Retool is preventing me from doing this. You probably are aware of the problem since you have already answered on the thread I opened about this topic:
Trigering queries in parallel make them overwrite each other

That is not an array of functions, it is an array of promises. They are not the same thing. I'm pointing it out so people doesn't get confused.

Hi Danielo,

Thank you for pointing that out, I have updated my reply as well.

I will continue to follow up in the other thread, as it seems that this issue is related to your specific implementation, rather than a general issue with running queries in parallel in Retool (which does work)

I too am having this exact same issue. I don't think its related to just Danielo's implementation.

Hey @Adub

Are you able to share the query that you are using / a screen recording showing the issue you are encountering?

I have been working with support on this for about two weeks now. Nasty internal bug. I think i'm good on retool.

Hey there @Adub

I am sorry that we weren't able to come to a solution with you on this issue so far. It looks like you still have a conversation open with one of my colleagues, but we haven't heard from you in a few days. If you would like to continue looking into this together, I am more than happy to continue the conversation and figure out what is going on with your queries.

For others who may come across this thread in the future, it seems that simpler examples of triggering multiple queries work without issue, but certain combinations of features may result in unexpected behavior. It seems like there may be an issue when triggering query library queries, but I have not been able to consistently reproduce this in my testing.

Just wanted to provide a quick update here, while continuing to investigate this issue with @Adub we were able to locate a bug with the query library, where variables defined in the query library queries are overwriting all instances of that variable in additionalScope used in queries in an app. Our engineering team will be investigating this further and hope to put out an update within the next few weeks to address this. I will update here when this patch is released!

Hi all,

Just wanted to follow up here to let you know that it looks like we merged a fix for this issue with query library queries and additional scope which should be included in todays release. If you have any additional questions or issues, please don't hesitate to reach out again!

1 Like