For the complete documentation index optimized for AI agents, see llms.txt.Queries for HelixDB are authored in Rust using the
helix-db crate (imported as
helix_db). This page covers bootstrapping a Rust project that builds your queries into the
queries.json bundle and lets you send them as dynamic requests. For the traversal model and
query patterns themselves, see Querying and the
docs.rs reference.
Prerequisites
- A recent stable Rust toolchain — install via rustup if you don’t already have it.
- Optional: the Helix CLI for running the resulting bundle against a local instance.
Create a new Rust project
generate_to_path is invoked from main, so a binary crate is the simplest layout:
Add the dependency
Cargo.toml:
helix-db but its module path is helix_db,
so all imports look like use helix_db::....
Set up src/main.rs
generate_to_path collects every query you’ve defined in the crate and writes a single
queries.json bundle to the path you pass. It returns the resolved path so you can log it or
hand it to a downstream deploy step.
Importing the DSL
Inside the modules where you author queries, bring the DSL into scope with the prelude:read_batch, write_batch, g(), sub(),
NodeRef/EdgeRef, Predicate/SourcePredicate, the projection helpers, and more. See the
docs.rs reference for the full surface.
Setting up your queries
Queries are defined as top-levelpub fn items annotated with #[register]. Each function
returns either a WriteBatch (for mutations) or a ReadBatch (for read-only traversals), and
generate_to_path picks them up automatically when the bundle is built. The function arguments
become the query’s named parameters at the HTTP edge.
For a small project you can keep everything in src/main.rs alongside fn main(); once you
have more than a handful of queries, move them into their own modules.
#[register]adds the function to the global bundle, sogenerate_to_pathpicks it up — no manual list to maintain.- Calling the function with concrete arguments returns a
DynamicQueryRequestyou POST to/v1/query; the request’squery_nameis set to the function name (so logs showadd_user, not__dynamic__). See Querying for the send path.
Generate the bundle
queries.json in the project root. From here you can:
- Mount it into the local
enterprise-devruntime asPATH_TO_QUERIES— see Local Development. - Deploy it to HelixDB through the control plane — see Working with HelixDB.
Next Steps
Querying
Traversal DSL, dynamic queries, and transactions.
Working with HelixDB
Deploy
queries.json and the runtime workflow.Local Development
Run the bundle locally with the
enterprise-dev image.DSL API Reference
Full
helix_db API on docs.rs.