[RFC] turbo query #9170
Replies: 3 comments 2 replies
-
What queries do you want?
Do you have other query languages that you’d prefer over GraphQL?
What would you build on top of this?
|
Beta Was this translation helpful? Give feedback.
-
First I'd like to say that I really love this feature. Being able to query the monorepo using a simple well known query language like graphql is amazing. What queries do you want?
Would you use another language? What would you build on top of this?
|
Beta Was this translation helpful? Give feedback.
-
Would this help with answering the question why a particular package gets rebuild instead of using a cache? |
Beta Was this translation helpful? Give feedback.
-
Abstract
turbo query
is a new command that lets you query data about your repository using GraphQL.How to try
In a repository using turbo@>2.1.0
Run
turbo query
to open a GraphiQL session. To directly execute a query, you can pass the query as a parameter:In a repository using turbo@<2.1.0
You can avoid upgrading your repository by using npx for a one-off turbo command.
We look forward to hearing your feedback on this feature!
Background
Turborepo computes a lot of data about your repository so that it can execute your tasks with maximum efficiency. This includes your package dependency graph, changed packages, task dependencies, log output from your tasks, and so on. This data is potentially quite useful for getting insights into your codebase, and also for third party tools.
Previously, Turborepo has added APIs for structured data, such as [run summaries](https://turbo.build/repo/docs/reference/run#--summarize) and [dry run](https://turbo.build/repo/docs/reference/run#--dry----dry-run). However, these APIs have some limitations. For one, they’re centered around a single run, not general repository info. Second, as we added more and more fields, the output quickly became rather bloated. For small repositories, that’s not a huge deal, but in larger codebases, this output started stretching into the megabytes.
We need a way to query repository data in a run-agnostic fashion, and make the returned data more customizable. However, we don’t intend on replacing dry run or run summaries. Our goal is to facilitate understanding in large repositories, while also making a tool that’s easy to use for everyone.
Solution
We’re introducing a new command,
turbo query
. This command will allow users to run GraphQL queries against Turborepo’s repository data.Running
turbo query
will open up GraphiQL, a custom IDE for writing GraphQL queries. Alternatively, you can pass the query directly as a string:turbo query "query { package(name: \"web\") { name } }"
or pass a file path:
Some example queries include:
Which packages have more than 10 immediate dependents:
They can get the changed packages within a git range
They can find a specific package and get its direct dependencies
And much more! To learn more, run
turbo query
on the latest canary to open up GraphiQL, GraphQL’s built in IDE, with a full schema explorer.We also plan on integrating live run output into this query interface, so you can query the status of your running tasks.
Feedback
We would love feedback on
turbo query
! The goal here is to help our users, i.e. you, create scripts and checks using Turbo’s knowledge. Therefore, it’s really important to us thatturbo query
works for you.Specifically, we would like to know:
Beta Was this translation helpful? Give feedback.
All reactions