GraphStore
Abstract interface for persisting and querying Knowledge Graphs.
All implementations must:
- Return consistent results for the same operations
- Use BFS-based traversal by default for consistent result ordering
- Return Left(Error) consistently for missing nodes/edges
- Support property filtering uniformly or document limitations
- Be thread-safe or explicitly document thread-safety guarantees
This trait is designed to be engine-agnostic, allowing implementations for various graph databases (Neo4j, TinkerPop, SPARQL, etc.) while maintaining a consistent interface.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
class InMemoryGraphStoreclass JsonGraphStore
Members list
Value members
Abstract methods
Deletes a specific edge.
Deletes a specific edge.
Value parameters
- relationship
-
The relationship type
- source
-
The source node ID
- target
-
The target node ID
Attributes
- Returns
-
Right(()) on success or if edge doesn't exist, Left(error) on failure
Deletes a node and all its connected edges.
Deletes a node and all its connected edges.
Value parameters
- id
-
The node ID to delete
Attributes
- Returns
-
Right(()) on success or if node doesn't exist, Left(error) on failure
Retrieves neighboring nodes and their connecting edges.
Retrieves neighboring nodes and their connecting edges.
Value parameters
- direction
-
The direction of traversal (Outgoing, Incoming, Both)
- nodeId
-
The ID of the node
Attributes
- Returns
-
Right(Seq of (edge, neighbor node)) on success, Left(error) on failure
Retrieves a node by ID.
Retrieves a node by ID.
Value parameters
- id
-
The node ID
Attributes
- Returns
-
Right(Some(node)) if found, Right(None) if not found, Left(error) on failure
Loads the entire graph.
Loads the entire graph.
For implementations backed by external databases, consider pagination or size limits to avoid memory issues with large graphs.
Attributes
- Returns
-
Right(graph) on success, Left(error) on failure
Queries the graph based on filter criteria. Returns a subgraph matching the filter conditions.
Queries the graph based on filter criteria. Returns a subgraph matching the filter conditions.
If propertyKey or propertyValue filters are specified but not supported, the implementation must either apply them or return a clear error.
Value parameters
- filter
-
The filter criteria
Attributes
- Returns
-
Right(subgraph) on success, Left(error) on failure
Computes statistics about the graph.
Computes statistics about the graph.
Attributes
- Returns
-
Right(stats) on success, Left(error) on failure
Traverses the graph starting from a node using BFS. All implementations must use Breadth-First Search for consistent result ordering.
Traverses the graph starting from a node using BFS. All implementations must use Breadth-First Search for consistent result ordering.
Missing start node: should return Right(Seq.empty) not an error, since traversal of a non-existent node yields no nodes.
Value parameters
- config
-
Traversal configuration (depth, direction, visited set). The direction parameter controls whether traversal follows outgoing, incoming, or all edges from each node.
- startId
-
The ID of the starting node
Attributes
- Returns
-
Right(Seq of traversed nodes) on success, Left(error) on critical failure
Inserts or updates an edge in the graph. Both source and target nodes must exist. If an edge with the same source, target, and relationship already exists, it is replaced.
Inserts or updates an edge in the graph. Both source and target nodes must exist. If an edge with the same source, target, and relationship already exists, it is replaced.
Value parameters
- edge
-
The edge to upsert
Attributes
- Returns
-
Right(()) on success, Left(error) if source or target nodes don't exist
Inserts or updates a node in the graph. If the node ID already exists, the existing node is replaced.
Inserts or updates a node in the graph. If the node ID already exists, the existing node is replaced.
Value parameters
- node
-
The node to upsert
Attributes
- Returns
-
Right(()) on success, Left(error) on failure