website/docs/concepts/query-lang.mdx
import VersionLabel from '@site/src/components/Docs/VersionLabel';
<VersionLabel version="1.3.0" header />moon supports an integrated query language, known as MQL, that can be used to filter and select
projects from the project graph, using an SQL-like syntax. MQL is primarily used by
moon run with the --query option.
A comparison (also known as an assignment) is an expression that defines a piece of criteria, and is a building block of a query. This criteria maps a field to a value, with an explicit comparison operator.
The equals (=) and not equals (!=) comparison operators can be used for exact value matching.
projectLayer=library && language!=javascript
You can also define a list of values using square bracket syntax, that will match against one of the values.
language=[javascript, typescript]
The like (~) and not like (!~) comparison operators can be used for wildcard value matching,
using glob syntax.
projectSource~packages/* && tag!~*-app
Like comparisons can only be used on non-enum fields.
The && and || logical operators can be used to combine multiple comparisons into a condition.
The && operator is used to combine comparisons into a logical AND, and the || operator is used
for logical OR.
taskToolchain=system || taskToolchain=node
For readability concerns, you can also use AND or OR.
taskToolchain=system OR taskToolchain=node
Mixing both operators in the same condition is not supported.
For advanced queries and complex conditions, you can group comparisons using parentheses to create logical groupings. Groups can also be nested within other groups.
language=javascript && (taskType=test || taskType=build)
The following fields can be used as criteria, and are related to task tokens.
languageProgramming language the project is written in, as defined in
moon.*.
language=rust
projectName OR alias of the project.
project=server
projectAliasAlias of the project. For example, the package.json name.
projectAlias~@scope/*
projectLayer<VersionLabel version="1.39.0" />The project layer, as defined in moon.*.
projectLayer=application
projectIdName of the project, as defined in .moon/workspace.*, or id in
moon.*.
projectId=server
projectSourceRelative file path from the workspace root to the project root, as defined in
.moon/workspace.*.
projectSource~packages/*
projectStack<VersionLabel version="1.22.0" />The project stack, as defined in moon.*.
projectStack=frontend
tagA tag within the project, as defined in moon.*.
tag~react-*
taskID/name of a task within the project.
task=[build,test]
taskToolchain<VersionLabel version="1.31.0" />The toolchain a task will run against, as defined in moon.*.
taskToolchain=node
taskTypeThe type of task, based on its configured settings.
taskType=build