Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(query): make immediate dependencies default #9114

Merged
merged 3 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions crates/turborepo-lib/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ impl Package {
}

/// The upstream packages that have this package as a direct dependency
async fn immediate_dependents(&self) -> Result<Vec<Package>, Error> {
async fn dependents(&self) -> Result<Vec<Package>, Error> {
let node: PackageNode = PackageNode::Workspace(self.name.clone());
Ok(self
.run
Expand All @@ -335,7 +335,7 @@ impl Package {
}

/// The downstream packages that directly depend on this package
async fn immediate_dependencies(&self) -> Result<Vec<Package>, Error> {
async fn dependencies(&self) -> Result<Vec<Package>, Error> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be direct_dependencies? Gives us the nice direct_dependencies U indirect_dependencies = dependencies relation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh indirect_dependencies is all transitive dependencies so it's more direct_dependencies ⊆ indirect_dependencies. I'm down to rename it if that's clearer (cc @anthonyshew)

let node: PackageNode = PackageNode::Workspace(self.name.clone());
Ok(self
.run
Expand All @@ -350,8 +350,8 @@ impl Package {
.collect())
}

/// The downstream packages that depend on this package, transitively
async fn dependents(&self) -> Result<Vec<Package>, Error> {
/// The downstream packages that depend on this package, indirectly
async fn indirect_dependents(&self) -> Result<Vec<Package>, Error> {
let node: PackageNode = PackageNode::Workspace(self.name.clone());

Ok(self
Expand All @@ -367,8 +367,8 @@ impl Package {
.collect())
}

/// The upstream packages that this package depends on, transitively
async fn dependencies(&self) -> Result<Vec<Package>, Error> {
/// The upstream packages that this package depends on, indirectly
async fn indirect_dependencies(&self) -> Result<Vec<Package>, Error> {
let node: PackageNode = PackageNode::Workspace(self.name.clone());

Ok(self
Expand Down
17 changes: 17 additions & 0 deletions turborepo-tests/integration/tests/command-query.t
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,23 @@ Get dependencies of `my-app`
"packages": [
{
"dependencies": [
{
"name": "util"
}
]
}
]
}
}

Get the indirect dependencies of `my-app`
$ ${TURBO} query "query { packages(filter: { equal: { field: NAME, value: \"my-app\" } }) { indirectDependencies { name } } }" | jq
WARNING query command is experimental and may change in the future
{
"data": {
"packages": [
{
"indirectDependencies": [
{
"name": "//"
},
Expand Down
Loading