Skip to content

Commit

Permalink
impl edge id for graphql and add test (#1868)
Browse files Browse the repository at this point in the history
Co-authored-by: Shivam Kapoor <[email protected]>
  • Loading branch information
shivam-880 and shivam-880 authored Nov 25, 2024
1 parent e289e5a commit 0414b7f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
40 changes: 40 additions & 0 deletions python/tests/graphql/edit_graph/test_graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,46 @@ def test_create_node_using_client_with_node_type():
assert "Node already exists" in str(excinfo.value)


def test_edge_id():
g = Graph()
g.add_edge(1, "ben", "shivam")
g.add_edge(2, "oogway", "po")
g.add_edge(3, "po", "ben")

tmp_work_dir = tempfile.mkdtemp()
with GraphServer(tmp_work_dir).start(port=1737):
client = RaphtoryClient("http://localhost:1737")
client.send_graph(path="g", graph=g)

query_nodes = """{graph(path: "g") {edges {list {id}}}}"""
assert client.query(query_nodes) == {
"graph": {
"edges": {
"list": [
{
"id": [
"ben",
"shivam"
]
},
{
"id": [
"oogway",
"po"
]
},
{
"id": [
"po",
"ben"
]
}
]
}
}
}


# def test_disk_graph_name():
# import pandas as pd
# from raphtory import DiskGraphStorage
Expand Down
5 changes: 5 additions & 0 deletions raphtory-graphql/src/model/graph/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ impl Edge {
self.ee.dst().into()
}

async fn id(&self) -> Vec<String> {
let (src_name, dst_name) = self.ee.id();
vec![src_name.to_string(), dst_name.to_string()]
}

async fn properties(&self) -> GqlProperties {
self.ee.properties().into()
}
Expand Down

0 comments on commit 0414b7f

Please sign in to comment.