Javascript Query in Query Library

Could the ability to create javascript queries be added to the query library? Would enable the ability to share javascript functions across apps.

5 Likes

+1 to this. would be really useful for sharing javascript queries across apps.

Is there a workaround for this?

Hi there!

Not currently :disappointed: Depending on your use case, you might find Preloaded Javascript helpful: https://docs.retool.com/docs/custom-js-code#preloaded-javascript

I'll post on this thread when we ship a fix!

I'm probably a little late to this, but we have been using a temporary workaround via modules.

It is done by creating a module that intake data, have a JavaScript query do whatever you want with the data, and export the query.data as an output.

Hope this helps!

1 Like

I am surprised it has taken me this long to realize the potential utility to have JS queries in the Query Library.

Since it could probably not see the calling app's state, I can see some limitations that would be fine with me:

You would need to pass all state into the query and return a result to communicate with the app. If the JS query triggered any other queries, they would need to themselves be on the query library.

My use case is I am running a series of actions that are duplicated in three different apps. They were rather simple until the client wanted them to do a lot more. There is no good way to modularize the actions as Modules do not have a "reason"able and reliable way for the parent to trigger one of it's query on demand.

I cannot use external or preloaded javascript as I need to run a few queries.

2 Likes

Thank you for sharing these details, @bradlymathews! I shared this feedback internally as well :slightly_smiling_face: