Query-Flow: A high-level query framework for incremental computation.
Built on top of [whale], this crate provides a user-friendly API for defining
and executing queries with automatic caching and dependency tracking.
Key Features
- Async-agnostic queries: Write sync query logic, run with sync or async runtime
- Automatic caching: Query results are cached and invalidated based on dependencies
- Suspense pattern: Handle async loading with
LoadingStatewithout coloring functions - Type-safe: Per-query-type caching with compile-time guarantees
- Early cutoff: Skip downstream recomputation when values don't change
Example
use query_flow::{query, QueryContext, QueryError, QueryRuntime};
#[query]
fn add(ctx: &mut QueryContext, a: i32, b: i32) -> Result<i32, QueryError> {
Ok(a + b)
}
let runtime = QueryRuntime::new();
let result = runtime.query(Add::new(1, 2)).unwrap();
assert_eq!(*result, 3);