type-bridge-server
Transport-agnostic query pipeline for TypeDB with composable interceptors.
Overview
type-bridge-server is both a library crate and a standalone binary that
provides a structured query pipeline for TypeDB:
validate → intercept → compile → execute → intercept
The pipeline receives structured queries (parsed AST clauses), validates them against a loaded TypeQL schema, runs request interceptors, compiles to TypeQL, executes against TypeDB, then runs response interceptors.
Quick start
As a standalone server
As a library
use PipelineBuilder;
use InMemorySchemaSource;
let pipeline = new
.with_schema_source
.with_default_database
.with_interceptor
.build?;
let output = pipeline.execute_query.await?;
Architecture
+-----------+
| Transport | (Axum HTTP, or custom)
+-----+-----+
|
+-----v-----+
| Pipeline |
+-----+-----+
|
+-------+-------+-------+-------+
| | | | |
Validate Intercept Compile Execute Intercept
(schema) (request) (AST→ (TypeDB) (response)
TypeQL)
Components:
| Component | Trait | Built-in |
|---|---|---|
| Executor | QueryExecutor |
TypeDBClient (feature: typedb) |
| Interceptor | Interceptor |
AuditLogInterceptor |
| Schema source | SchemaSource |
FileSchemaSource, InMemorySchemaSource |
| Transport | N/A | Axum HTTP (feature: axum-transport) |
Configuration
The server reads a TOML config file:
[]
= "localhost:1729"
= "my_database"
= "admin"
= "password"
[]
= "0.0.0.0" # default
= 3000 # default
[]
= "schema.tql" # optional: path to TypeQL schema
[]
= ["audit-log"]
[]
= "file" # "stdout" or "file"
= "/var/log/audit.jsonl"
[]
= "info" # default
= "text" # "text" or "json"
HTTP API
All endpoints require Content-Type: application/json.
POST /query — execute structured query
POST /query/raw — execute raw TypeQL
POST /query/validate — validate without executing
GET /health — health check
Returns {"status": "ok", "connected": true}.
GET /schema — loaded schema
Returns the loaded TypeQL schema as JSON, or 500 if no schema is loaded.
Custom interceptors
Implement the Interceptor trait to add cross-cutting concerns:
use ;
use Clause;
use Pin;
use Future;
Register via PipelineBuilder::with_interceptor().
Custom executors
Implement QueryExecutor for non-TypeDB backends or mocking:
use QueryExecutor;
use PipelineError;
use Pin;
use Future;
;
Feature flags
| Feature | Default | Effect |
|---|---|---|
typedb |
yes | Enables TypeDBClient and typedb-driver dependency |
axum-transport |
yes | Enables HTTP server with Axum |
Build as bare library (no transport, no TypeDB):
Testing
# Unit tests (no external dependencies)
# MC/DC coverage (requires nightly + cargo-llvm-cov)