use schemars::JsonSchema;
use serde::Deserialize;
use graphyn_core::graph::GraphynGraph;
use graphyn_core::query;
use crate::context_builder;
#[derive(Debug, Deserialize, JsonSchema)]
pub struct DependenciesParams {
pub symbol: String,
pub file: Option<String>,
pub depth: Option<i32>,
}
pub fn execute(graph: &GraphynGraph, params: DependenciesParams) -> Result<String, String> {
let depth = params.depth.unwrap_or(3).clamp(1, 10) as usize;
let edges = query::dependencies(graph, ¶ms.symbol, params.file.as_deref(), Some(depth))
.map_err(|e| format!("{e}"))?;
Ok(context_builder::format_dependencies(
graph,
¶ms.symbol,
params.file.as_deref(),
depth,
&edges,
))
}