Query Library has a huge potential in retool but for now i feel like it's not worth the effort.
It's just easier to recreate the query on each module/app because we have to setup all over again when using query library.
Here are suggestions to make it really powerful separated by topics:
Documentation:
It's nice to be able to understand the purpose of a query, or describe how it works, or give examples on how to use it, show different possibilities. Right now this is not possible.
Suggestions:
- be able to right a real description or overview of it (right now we can right a description with size limit of a small phrase)
- create a way of indicate that a "param" (additionalScope) is required or not
- import query from postman (many external APIs have documentation and examples on services like postman, would be nice to import their setup)
- import markdown file as overview/description
Query behavior setup
- Everything related to when to trigger a query should be in the same place. It's very bad UX setting a query as Manual, but in another tab we have a section that we can set it to trigger on page load or in interval. Then in another section we can set if it should be disabled in certain condition, and watch inputs. All this is related and becomes annoying to have to navigate to different parts of the setup to really understand what "Manually trigger" means
- Watch inputs should not be limited to only used variables. Why that?
- When importing a query from query library we face a bug with watch inputs (if watched inputs wasn't limited, the bug wouldn't exist).
Let's reproduce the Query Library Watch Input "bug"
-
Imagine you have a query in query Library with additional scope or param or query params. For example a param "userId"
-
Now you import this query and set it to be Manually Triggered.
-
Now you want to watch some value.
-
This is limited and you can only watch the query library "variables"
-
In this case the only thing retool will let us watch is
{{ userId || "" }}
or{{ userId }}
if you want the query to fetch only specified user
-
In our app/module we have a table with users that we can select and when selected we want more information about this user
-
This is a problem because in your local application we would have to watch
{{ usersTable.selectedRowKey }}
otherwise it won't trigger when this variable change -
To make it work, we would have to change the query to use the same name of the variable we are passing to it.
-
Let's go around this by creating in our app a variable or transformer called
userId
to have the value of the selected row (already bad) -
We still can't trigger automatically because we can only watch
{{userId}}
but not it's value -
Finally the ultimate work around solution, go back to the query and use it like this
{{userId.value || ""}}
-
In app, now you will be able to track the real variable value
-
Now we to pass the variable value to our "query var". It would look like this: "userId.value = {{ userId.value }}"
-
Finally we get our trigger working as we expect
-
Disappointing
Middlewares
When we create a query we expected the values to have a specific format. So we create some workflow similar to this: formatting ->validating->api query
.
We can call it middlewares. If i'm adding a query to the query library it is likely that it will be reused by multiple apps/modules.
Why would I recreate the middlewares all over again every time?
- query in general, including the ones in query library should have middlewares or workflows. If it's a local query, it's easier to prepare data for the query, and in case of query library, those steps can be also reused
- another way is to make easier to integrate it with retool workflows. A different type of trigger. Right now it's a annoying extra step for calling an extra query to trigger the retool workflow that will be responsible to call the real api endpoint we wanted at first
Event Handlers
Sometimes it happens that we want to trigger some retool workflow whenever we run some query, or call another query right after. Right now we can do it locally to revalidate some query. But what if this query should trigger something else independent of where it was called.
- add event handlers for queries in query libraries that can be merged with other event handlers passed by the local module using it
Test Params
Imagine you have a POST request where you need to pass a few variables that we gonna use it at our request body. We can set them on right sidepanel pretty easy. Now imagine that we have multiple variables to set. We also have some example of body that we can use. I can change my query and paste it manually as a raw body, and then ctrl+z to return how it was. Or i could have a way of pasting this body in variables without having to make any changes to my query setup.
Right now i have to create a new variable called "payload" and use it like this:
//Raw body {{ payload || {var1: var1, var2: var2} }}
- add a easy way to paste a payload without editing the query
Query Return (for query library or local queries)
Whenever you have an Output/Preview of a query or a transformer, the visualization of the data it's nice but some times i want to copy it to somewhere else and the text format don't allow me to copy. I have to JSON.strigify(value) and take it from debugger console. We can't search for something inside the output either. I can search using the browser search, but it will find things in the entire page, or copy the output to somewhere else to be able to search something properly.
- add a easy way to copy the output of a query or transformer or.....
- add a search specific for the output/preview
Conclusion
I like retool and those improvements would really take it to a next level.
But for now feels bad that we need to do workarounds for so many things.
I haven't even mentioned the lack of pure js functions which is in beta for 1 year (sync functions) and i have to use js query with additional scope to mimic a normal method.
I really expect those changes or your own solutions (real solutions and not workarounds) for those problems.