Documentation Index
Fetch the complete documentation index at: https://docs.helix-db.com/llms.txt
Use this file to discover all available pages before exploring further.
For the complete documentation index optimized for AI agents, see llms.txt.Stored queries for HelixDB are authored in Rust using the
helix-enterprise-ql crate (imported as
helix_dsl). This page covers bootstrapping a Rust project that builds your queries into the
queries.json bundle that the runtime consumes. 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-enterprise-ql but its module path is helix_dsl,
so all imports look like use helix_dsl::....
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, the traversal
builder g(), sub-traversal sub(), NodeRef/EdgeRef, Predicate/SourcePredicate, the
projection helpers (PropertyProjection, ExprProjection), and AggregateFunction. See the
docs.rs reference for the full surface
and Querying for how the pieces fit together.
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]registers the function with the global query bundle sogenerate_to_pathwill include it inqueries.json. No manual list to maintain.- The function name becomes the route name. Once deployed, callers invoke
POST /v1/query/add_userwith a JSON body like{"userId": "u-1", "name": "Alice"}. - The
let _ = (&userId, &name);line silences Rust’s unused-variable warning — the macro reads the parameter names at compile time to wire them into the JSON schema, so the values themselves aren’t used in the body. var_as("name", traversal)binds a sub-result, and.returning([...])chooses which bound names appear in the response payload.
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, stored queries, 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_dsl API on docs.rs.