use std::sync::Arc;
use crate::db::graph::{GraphDb, SubgraphQueryExt};
use crate::models::{SubgraphDirection, SubgraphQueryOptions, SubgraphResult};
pub const DEFAULT_MAX_NODES: usize = 500;
#[allow(clippy::too_many_arguments)]
pub async fn run_get_subgraph(
entity_name: &str,
repo_name: &str,
depth: u32,
relationships: &[&str],
direction: SubgraphDirection,
max_nodes: Option<usize>,
graph_db: &Arc<GraphDb>,
entity_uuid: Option<&str>,
visible_kinds: Option<&[&str]>,
) -> anyhow::Result<SubgraphResult> {
let max_nodes = max_nodes.unwrap_or(DEFAULT_MAX_NODES);
let result = graph_db
.get_entity_subgraph(SubgraphQueryOptions {
entity_name,
repo_name,
depth,
relationships,
direction,
max_nodes,
entity_uuid,
visible_kinds,
})
.await?;
Ok(result)
}