1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! 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
//!
//! ```no_run
//! // 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()
//! }
//! ```
use Pin;
use crate::;
/// Type-erased executor interface.
///
/// Allows code that drives query execution (`fraiseql-server`, tests) to hold
/// `Arc<dyn ExecutorAdapter>` without being generic over `DatabaseAdapter`.
///
/// Concrete implementations should implement this trait on their
/// `Executor<A>` type to participate in the type-erased execution path.