Documentation Index
Fetch the complete documentation index at: https://databridge-add-core-funcs.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
def get_graph(
name: str,
folder_name: Optional[Union[str, List[str]]] = None,
folder_depth: Optional[int] = None,
end_user_id: Optional[str] = None,
) -> Graph
async def get_graph(
name: str,
folder_name: Optional[Union[str, List[str]]] = None,
folder_depth: Optional[int] = None,
end_user_id: Optional[str] = None,
) -> Graph
Parameters
name (str): Name of the graph to retrieve
folder_name (str | List[str], optional): Optional folder scope. Accepts canonical paths or a list of paths/names.
folder_depth (int, optional): Folder scope depth. None/0 = exact match, -1 = include all descendants, n > 0 = include descendants up to n levels deep.
end_user_id (str, optional): Optional end-user scope.
Returns
Graph: The requested graph object. If the graph is still building it will
have system_metadata["status"] == "processing". Use the convenience
helpers graph.is_processing, graph.is_completed, graph.error, or the
client-level wait_for_graph_completion() to monitor progress.
Examples
from morphik import Morphik
db = Morphik()
# Get a graph by name
graph = db.get_graph("finance_graph")
# Or fetch by path and include nested folders
nested_graph = db.get_graph("finance_graph", folder_name="/projects/alpha", folder_depth=-1)
if graph.is_processing:
print("Graph still processing, waiting...")
graph = db.wait_for_graph_completion("finance_graph")
# Now safe to access entities and relationships
print(f"Graph has {len(graph.entities)} entities and {len(graph.relationships)} relationships")
# Access entities and relationships
for entity in graph.entities:
print(f"Entity: {entity.label} ({entity.type})")
for relationship in graph.relationships:
source_entity = next((e for e in graph.entities if e.id == relationship.source_id), None)
target_entity = next((e for e in graph.entities if e.id == relationship.target_id), None)
if source_entity and target_entity:
print(f"Relationship: {source_entity.label} --{relationship.type}--> {target_entity.label}")
from morphik import AsyncMorphik
async with AsyncMorphik() as db:
# Get a graph by name
graph = await db.get_graph("finance_graph")
nested_graph = await db.get_graph(
"finance_graph",
folder_name="/projects/alpha",
folder_depth=-1,
)
if graph.is_processing:
print("Graph still processing, waiting...")
graph = await db.wait_for_graph_completion("finance_graph")
# Now safe to access entities and relationships
print(f"Graph has {len(graph.entities)} entities and {len(graph.relationships)} relationships")
# Access entities and relationships
for entity in graph.entities:
print(f"Entity: {entity.label} ({entity.type})")
for relationship in graph.relationships:
source_entity = next((e for e in graph.entities if e.id == relationship.source_id), None)
target_entity = next((e for e in graph.entities if e.id == relationship.target_id), None)
if source_entity and target_entity:
print(f"Relationship: {source_entity.label} --{relationship.type}--> {target_entity.label}")
Graph Properties
The returned Graph object has the following properties:
id (str): Unique graph identifier
name (str): Graph name
entities (List[Entity]): List of entities in the graph
relationships (List[Relationship]): List of relationships in the graph
metadata (Dict[str, Any]): Graph metadata
document_ids (List[str]): Source document IDs
filters (Dict[str, Any], optional): Document filters used to create the graph
created_at (datetime): Creation timestamp
updated_at (datetime): Last update timestamp
owner (Dict[str, str]): Graph owner information
folder_path (Optional[str]): Canonical folder path for the graph (if scoped)
Entity Properties
Each Entity object has the following properties:
id (str): Unique entity identifier
label (str): Display label for the entity
type (str): Entity type
properties (Dict[str, Any]): Entity properties
document_ids (List[str]): Source document IDs
chunk_sources (Dict[str, List[int]]): Source chunk numbers by document ID
Relationship Properties
Each Relationship object has the following properties:
id (str): Unique relationship identifier
source_id (str): Source entity ID
target_id (str): Target entity ID
type (str): Relationship type
document_ids (List[str]): Source document IDs
chunk_sources (Dict[str, List[int]]): Source chunk numbers by document ID