diff --git a/raphtory-graphql/src/model/mod.rs b/raphtory-graphql/src/model/mod.rs index d055bdd8b..613f57f44 100644 --- a/raphtory-graphql/src/model/mod.rs +++ b/raphtory-graphql/src/model/mod.rs @@ -222,6 +222,27 @@ impl Mut { data.insert_graph(path, g).await?; Ok(path.to_owned()) } + + /// Create a subgraph out of some existing graph in the server + /// + /// Returns:: + /// name of the new graph + async fn create_subgraph<'a>( + ctx: &Context<'a>, + parent_path: &str, + nodes: Vec, + new_path: String, + overwrite: bool, + ) -> Result { + let data = ctx.data_unchecked::(); + let parent_graph = data.get_graph(parent_path)?.0.graph; + let new_subgraph = parent_graph.subgraph(nodes).materialize()?; + if overwrite { + let _ignored = data.delete_graph(&new_path); + } + data.insert_graph(&new_path, new_subgraph).await?; + Ok(new_path) + } } #[derive(App)]