Skip to content

Graph-Native Infrastructure for Context and Accountable AI Systems

fix(docs): use GraphStore facade in Neo4j quickstart (#1340)

Sameer Kadam46b18fbee31e
diff --git a/docs/quickstart.md b/docs/quickstart.md
index 31b08970..d802dc5e 100644
--- a/docs/quickstart.md
+++ b/docs/quickstart.md
@@ -327,10 +327,11 @@ print(f"Relationships active in 2023: {result_2023['num_relationships']}")
<Accordion title="Persistent graph store: Neo4j, FalkorDB, Apache AGE" icon="database">
```python
-from semantica.graph_store import Neo4jStore
+from semantica.graph_store import GraphStore
from semantica.kg import GraphBuilder
-store = Neo4jStore(
+store = GraphStore(
+ backend="neo4j",
uri="bolt://localhost:7687",
user="neo4j",
password="password",
diff --git a/tests/kg/test_graph_builder_with_graph_store.py b/tests/kg/test_graph_builder_with_graph_store.py
new file mode 100644
index 00000000..7f8e6c4c
--- /dev/null
+++ b/tests/kg/test_graph_builder_with_graph_store.py
@@ -0,0 +1,97 @@
+"""
+Test for GraphBuilder with GraphStore backend (Issue #1135).
+
+This test verifies that GraphBuilder correctly works with the GraphStore
+facade interface, not with raw backend stores like Neo4jStore.
+"""
+import unittest
+from unittest.mock import MagicMock, patch
+
+
+class TestGraphBuilderWithGraphStore(unittest.TestCase):
+ """Test GraphBuilder integration with GraphStore facade."""
+
+ def setUp(self):
+ """Set up test fixtures."""
+ # Mock progress tracker
+ self.mock_tracker_patcher = patch("semantica.utils.progress_tracker.get_progress_tracker")
+ self.mock_get_tracker = self.mock_tracker_patcher.start()
+ self.mock_tracker = MagicMock()
+ self.mock_get_tracker.return_value = self.mock_tracker
+
+ def tearDown(self):
+ """Clean up after tests."""
+ self.mock_tracker_patcher.stop()
+
+ def test_graph_builder_with_graph_store_facade(self):
+ """Test that GraphBuilder works with GraphStore facade (Issue #1135)."""
+ from semantica.kg.graph_builder import GraphBuilder
+ from semantica.graph_store import GraphStore
+
+ # Create a mock GraphStore facade
+ mock_store = MagicMock(spec=GraphStore)
+ mock_store.add_nodes.return_value = 2
+ mock_store.add_edges.return_value = 1
+
+ # Create GraphBuilder with the GraphStore facade
+ builder = GraphBuilder(
+ merge_entities=False,
+ resolve_conflicts=False,
+ graph_store=mock_store
+ )
+
+ # Build a simple graph
+ entities = [
+ {"id": "alice", "type": "Person"},
+ {"id": "bob", "type": "Person"},
+ ]
+ relationships = [
+ {"source": "alice", "target": "bob", "type": "knows"},
+ ]
+
+ graph = builder.build({
+ "entities": entities,
+ "relationships": relationships
+ })
+
+ # Verify the graph was built
+ self.assertEqual(len(graph["entities"]), 2)
+ self.assertEqual(len(graph["relationships"]), 1)
+
+ # Verify that add_nodes and add_edges were called on the GraphStore
+ mock_store.add_nodes.assert_called_once()
+ mock_store.add_edges.assert_called_once()
+
+ def test_graph_builder_without_graph_store_still_works(self):
+ """Test that GraphBuilder still works without a graph_store parameter."""
+ from semantica.kg.graph_builder import GraphBuilder
+
+ # Create GraphBuilder without graph_store
+ builder = GraphBuilder(
+ merge_entities=False,
+ resolve_conflicts=False
+ )
+
+ # Build a simple graph
+ entities = [
+ {"id": "alice", "type": "Person"},
+ {"id": "bob", "type": "Person"},
+ ]
+ relationships = [
+ {"source": "alice", "target": "bob", "type": "knows"},
+ ]
+
+ graph = builder.build({
+ "entities": entities,
+ "relationships": relationships
+ })
+
+ # Verify the graph was built
+ self.assertEqual(len(graph["entities"]), 2)
+ self.assertEqual(len(graph["relationships"]), 1)
+ self.assertEqual(graph["metadata"]["num_entities"], 2)
+ self.assertEqual(graph["metadata"]["num_relationships"], 1)
+
+
+if __name__ == "__main__":
+ unittest.main()