diff --git a/crates/turborepo-lib/src/query/mod.rs b/crates/turborepo-lib/src/query/mod.rs index 643b87d07defb..49e8443d40489 100644 --- a/crates/turborepo-lib/src/query/mod.rs +++ b/crates/turborepo-lib/src/query/mod.rs @@ -288,6 +288,7 @@ impl RepositoryQuery { &self, base: Option, head: Option, + filter: Option, ) -> Result, Error> { let mut opts = self.run.opts().clone(); opts.scope_opts.affected_range = Some((base, head)); @@ -304,6 +305,7 @@ impl RepositoryQuery { run: self.run.clone(), name: package, }) + .filter(|package| filter.as_ref().map_or(true, |f| f.check(package))) .sorted_by(|a, b| a.name.cmp(&b.name)) .collect()) } diff --git a/turborepo-tests/integration/tests/affected.t b/turborepo-tests/integration/tests/affected.t index b35b50b173031..9f20f4408e939 100644 --- a/turborepo-tests/integration/tests/affected.t +++ b/turborepo-tests/integration/tests/affected.t @@ -367,4 +367,22 @@ Do the same thing with the `query` command ] } } - } \ No newline at end of file + } + +Use a filter with `affectedPackages` + $ ${TURBO} query "query { affectedPackages(filter: { equal: { field: NAME, value: \"my-app\" } }) { items { name } } }" + WARNING query command is experimental and may change in the future + WARNING unable to detect git range, assuming all files have changed: git error: fatal: no merge base found + + { + "data": { + "affectedPackages": { + "items": [ + { + "name": "my-app" + } + ] + } + } + } +