graflo.db.cypher¶
Shared Cypher query fragments (no drivers; safe string builders only).
cypher_map_key(name)
¶
Return a backtick-quoted map-key / property name for Cypher patterns.
Strips embedded backticks from name so callers cannot break out of quotes.
Source code in graflo/db/cypher/escape.py
cypher_neighbors_query(*, anchor_label, anchor_id, anchor_key_field='id', edge_type, far_label, direction, hops, limit)
¶
Render a bounded neighbourhood query.
Returns the reached nodes and their distance, deduplicated. DISTINCT is
load-bearing: a graph with a cycle reaches the same node by several paths,
and without it the row count grows with path multiplicity rather than with
neighbourhood size.
Source code in graflo/db/cypher/traversal.py
cypher_rel_pattern(edge_type, direction=EdgeDirection.OUT, *, variable='r', min_hops=None, max_hops=None)
¶
Render the relationship pattern between two node patterns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_type
|
str | None
|
Relationship type to filter on, or None for any type. |
required |
direction
|
EdgeDirection
|
Orientation followed from the left-hand (anchor) node. |
OUT
|
variable
|
str
|
Relationship variable name bound in the pattern. |
'r'
|
min_hops
|
int | None
|
Lower bound for a variable-length pattern. Defaults to 1 when only max_hops is given. |
None
|
max_hops
|
int | None
|
Upper bound for a variable-length pattern. Omitting both keeps the single-hop form, which is what every existing caller wants. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
e.g. |
str
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
if the hop bounds are non-positive or inverted — an
unbounded |
Source code in graflo/db/cypher/direction.py
cypher_string_literal(value)
¶
rel_merge_props_map_from_row_index(prop_names, *, row_index=2)
¶
Build `k`: row[n]['k'], ... for MERGE relationship properties.
Matches batches shaped as row = [source_doc, target_doc, props] (Neo4j,
FalkorDB-style row[2]).
Source code in graflo/db/cypher/rel_merge.py
rel_merge_props_map_from_row_props(prop_names, *, props_expr='row.props')
¶
Build `k`: row.props['k'], ... (Memgraph-style batch rows).