A lightweight mapping layer for Neo4j that preserves raw Cypher control while adding strong Rust types around nodes, relationships, and query results. Write real Cypher — derive the rest.
The problem
Traditional ORMs hide your database behind abstractions. Graph databases don't survive that treatment — Cypher is expressive, and flattening it into a builder API loses the point. But writing raw queries without type safety means runtime surprises, manual deserialization, and silent breakage when your schema drifts.
How it works
You write real Cypher queries. Cyphr's derive macros (CyphrNode, CyphrRelation, FromCyphr) handle the mapping between Neo4j's Bolt protocol and your Rust structs at compile time. Query results are projected directly into typed structs — no manual row parsing, no runtime reflection.
Type
Safe
Cypher
First
Zero
Overhead
neo4rs
0.8
Core components
CyphrNode derive
Marks structs representing graph nodes. Handles label mapping, ID fields, and property name overrides.
CyphrRelation derive
Defines relationship types with source/target constraints. Type-safe graph edges.
FromCyphr derive
Maps query result rows to Rust structs. Supports flattening, optional fields, and nested composition.
cypher_query! macro
Query builder with automatic parameter binding. Write Cypher inline, reference Rust variables directly.
ToCyphrParams derive
Converts Rust structs into parameterised query inputs for safe writes.
Fetch patterns
- →
fetch_one— single row, fails if absent - →
fetch_optional— single row or None - →
fetch_all— collect all rows into a Vec - →
fetch_stream— async stream for large result sets - → All patterns support transactional variants via
_insuffix
Quick start
# Add to Cargo.toml
cyphr = { git = "https://github.com/ikcore/cyphr" }
Design philosophy: Cyphr is not an ORM. It doesn't generate queries, manage migrations, or hide your database behind abstractions. It gives you the type safety Rust developers expect — without taking away the Cypher you already know.