Using app queries correctly with modules

I have a main app using a couple queries I need for the integrated module. The only way I managed to get this to work is to take the existing query and "Extract to Query Library", then in the module add a query and "Import from Query Library".

chrome_CRAo3HtddA

This solution works but as the module is in the app it seems inefficient as the query is being called twice.

How would I properly set up the module to "use" the existing query results from the main app?

Hey @Shawn_Optipath, you can pass queries from parent apps to your module.
Modules can trigger the passed queries directly, calling them in event handlers and as success and failure trigger queries, which will also reload the data in the parent app.

Also see: Build modules to reuse queries and components | Retool Docs

1 Like

Hey @TobiasOhlsson. Thanks for pointing me in the right direction. So in my case in the parent app I have a query getEquipmentType . I need to use the data from this in the module.

In the module I have a checkbox where the data is mapped from the query:
chrome_XkDHnSkfZN

I'm not sure how to set this up:

chrome_CYzeydRTI9

The other thing is the module does not need to trigger the query. I just need access to the data.

@Shawn_Optipath sounds like you can just use the "Data" input type then.

Create an input with type data, and add some dummy data so that you can test properly in your module:

In your module, add the module input anywhere you need to reference the query's data (as inputName.value):
CleanShot 2024-12-05 at 14.42.52@2x

Then, in the app, you can pass the query's data to the input (see the below screenshot where my app query's data is shown in my module's table):

1 Like