Repository: Pometry/Raphtory (language: python)

Issue:
Add edge ID to graphql
Would be helpful to be able to directly get the id of an edge instead of having to do {src{name} dst{name}}


Discussion / hints:

Fix patch:
diff --git a/raphtory-graphql/src/model/graph/edge.rs b/raphtory-graphql/src/model/graph/edge.rs
index becccbf61..07e14cf00 100644
--- a/raphtory-graphql/src/model/graph/edge.rs
+++ b/raphtory-graphql/src/model/graph/edge.rs
@@ -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()
     }


Test patch:
diff --git a/python/tests/graphql/edit_graph/test_graphql.py b/python/tests/graphql/edit_graph/test_graphql.py
index a75d6259f..ba863c99e 100644
--- a/python/tests/graphql/edit_graph/test_graphql.py
+++ b/python/tests/graphql/edit_graph/test_graphql.py
@@ -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