Share queries with the Query Playground
Learn how to import and export queries with the Query Playground.
You're viewing documentation for classic apps, which use Retool's original app editor. The AI app builder is the recommended way to build apps and where Retool focuses new development.
You can use the same query across multiple apps by sharing them with the Query Playground. Often, you want the same functionality across apps, but don’t want to copy paste the same query over and over again. Reusable queries help you avoid code duplication, version control queries, and share queries with your team.
Navigate to the Query playground by clicking Resources, then Query Playground.
Write your query
Reusable queries are written in the Query Playground. To set up a reusable query:
- Create and configure a query.
- Save the query.
- Share the query using the Share button. This makes your query visible and editable to every Editor in your team. You can also import the query in your apps.
By default all users have access to the Query Playground. If you're an admin, you can configure which user groups have access to the Query Playground in your Permission settings.
You can define variables for queries using curly braces {{ }}. Variables are dynamic inputs to your query. You can define defaults in the Variables section of the right hand panel. When you import a query in a Retool app, you can pass inputs to the variables you define.
Tip: You can write JavaScript inside the {{ }} curly braces