Skip to main content

Module executor_adapter

Module executor_adapter 

Source
Expand description

Type-erased executor interface.

This module provides ExecutorAdapter, a trait that allows code driving query execution (e.g., fraiseql-server, tests) to hold an Arc<dyn ExecutorAdapter> without being generic over a concrete DatabaseAdapter type parameter.

§Design Rationale

Executor<A> is generic over its database adapter. Without type erasure, every struct that holds an executor — the HTTP server, middleware, test harnesses — must carry that type parameter, which produces significant generic noise and makes dynamic dispatch impossible.

ExecutorAdapter solves this by providing a single object-safe trait that concrete Executor<A> implementations can implement, enabling uniform Arc<dyn ExecutorAdapter> storage.

§Example

// Requires: a concrete ExecutorAdapter implementation.
use fraiseql_core::runtime::{ExecutionContext, ExecutorAdapter};
use std::sync::Arc;

async fn run_query(exec: Arc<dyn ExecutorAdapter>, query: &str) -> String {
    let ctx = ExecutionContext::new("query-1".to_string());
    exec.execute_with_context(query, None, &ctx).await.unwrap()
}

Traits§

ExecutorAdapter
Type-erased executor interface.