Skip to content

Commit

Permalink
adding methods for layered edges in graphql (Pometry#1331)
Browse files Browse the repository at this point in the history
* adding methods for layered edges in graphql

* adding methods for layered edges in graphql

* added start and end
  • Loading branch information
rachchan authored Oct 16, 2023
1 parent 3d8a18d commit 4a7b025
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
33 changes: 28 additions & 5 deletions raphtory-graphql/src/model/graph/edge.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
use crate::model::graph::node::Node;
use dynamic_graphql::{ResolvedObject, ResolvedObjectFields};
use itertools::Itertools;
use raphtory::db::{
api::view::{
internal::{DynamicGraph, IntoDynamic},
EdgeViewOps, GraphViewOps,
use raphtory::{
db::{
api::view::{
internal::{DynamicGraph, IntoDynamic},
EdgeViewOps, GraphViewOps,
},
graph::edge::EdgeView,
},
graph::edge::EdgeView,
prelude::{LayerOps, TimeOps},
};

#[derive(ResolvedObject)]
Expand Down Expand Up @@ -35,6 +38,14 @@ impl Edge {
self.ee.latest_time()
}

async fn start(&self) -> Option<i64> {
self.ee.start()
}

async fn end(&self) -> Option<i64> {
self.ee.end()
}

async fn src(&self) -> Node {
self.ee.src().into()
}
Expand All @@ -47,10 +58,22 @@ impl Edge {
self.ee.properties().get(name).map(|prop| prop.to_string())
}

async fn layer(&self, layer_name: &str) -> Option<Edge> {
self.ee.layer(layer_name).map(|ee| ee.into())
}

async fn layers(&self) -> Vec<String> {
self.ee.layer_names().map_into().collect()
}

async fn layer_exploded_edges(&self) -> Vec<Edge> {
self.ee
.explode_layers()
.into_iter()
.map(|ee| ee.into())
.collect_vec()
}

async fn history(&self) -> Vec<i64> {
self.ee.history()
}
Expand Down
8 changes: 8 additions & 0 deletions raphtory-graphql/src/model/graph/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ impl Node {
self.vv.name()
}

async fn start(&self) -> Option<i64> {
self.vv.start()
}

async fn end(&self) -> Option<i64> {
self.vv.end()
}

pub async fn node_type(&self) -> String {
self.vv
.properties()
Expand Down

0 comments on commit 4a7b025

Please sign in to comment.