Skip to main content

fraiseql_core/
lib.rs

1//! # FraiseQL Core
2//!
3//! Core execution engine for FraiseQL v2 - A compiled GraphQL execution engine.
4
5#![warn(clippy::missing_errors_doc)]
6#![warn(clippy::missing_panics_doc)]
7
8//! ## Architecture
9//!
10//! FraiseQL v2 compiles GraphQL schemas into optimized SQL execution plans at build time,
11//! eliminating runtime overhead and enabling deterministic, high-performance query execution.
12//!
13//! ### Key Components
14//!
15//! - **Schema**: Compiled schema representation (reused from v1)
16//! - **Compiler**: GraphQL schema → SQL template compiler (new for v2)
17//! - **Runtime**: Compiled query executor (new for v2)
18//! - **Database**: Connection pooling and transaction management (from v1)
19//! - **Cache**: Query result caching with coherency (from v1)
20//! - **Security**: Authentication, authorization, and audit (from v1)
21//! - **APQ**: Automatic Persisted Queries (from v1)
22//!
23//! ## Compilation Flow
24//!
25//! ```text
26//! Python/TypeScript Decorators
27//!         ↓
28//!    JSON Schema
29//!         ↓
30//!     Compiler
31//!    ↙    ↓    ↘
32//! Parse Validate Codegen
33//!         ↓
34//!  CompiledSchema.json
35//!         ↓
36//!      Runtime
37//!    ↙    ↓    ↘
38//! Match Execute Project
39//!         ↓
40//!   GraphQL Response
41//! ```
42//!
43//! ## Example
44//!
45//! ```ignore
46//! use fraiseql_core::schema::CompiledSchema;
47//! use fraiseql_core::runtime::Executor;
48//!
49//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
50//! // Load compiled schema
51//! let schema = CompiledSchema::from_file("schema.compiled.json")?;
52//!
53//! // Create executor
54//! let executor = Executor::new(schema, db_pool).await?;
55//!
56//! // Execute query
57//! let query = r#"query { users { id name } }"#;
58//! let result = executor.execute(query, None).await?;
59//!
60//! println!("{}", result);
61//! # Ok(())
62//! # }
63//! ```
64
65#![forbid(unsafe_code)]
66// Missing docs allowed for internal items - public API is fully documented
67#![allow(missing_docs)]
68#![warn(clippy::all)]
69#![warn(clippy::pedantic)]
70// Allow common pedantic lints that are too noisy for this codebase
71#![allow(clippy::doc_markdown)] // Would require 150+ doc changes for backticks
72#![allow(clippy::return_self_not_must_use)] // Builder pattern doesn't always need #[must_use]
73#![allow(clippy::uninlined_format_args)] // Style preference, not a bug
74#![allow(clippy::unused_self)] // Often needed for trait consistency
75#![allow(clippy::unnecessary_wraps)] // Sometimes needed for API consistency
76#![allow(clippy::must_use_candidate)] // Too noisy for builder methods
77#![allow(clippy::missing_errors_doc)] // Would require extensive doc additions
78#![allow(clippy::module_name_repetitions)] // Common in Rust APIs
79#![allow(clippy::match_same_arms)] // Sometimes clearer to be explicit
80#![allow(clippy::cast_possible_truncation)] // Many intentional u64->u32 casts
81#![allow(clippy::cast_precision_loss)] // Intentional f64 conversions
82#![allow(clippy::cast_sign_loss)] // Intentional signed->unsigned conversions
83#![allow(clippy::too_many_arguments)] // Some complex functions need many args
84#![allow(clippy::format_push_string)] // Sometimes clearer than write!
85#![allow(clippy::redundant_closure_for_method_calls)] // Sometimes clearer
86#![allow(clippy::explicit_iter_loop)] // Explicit .iter() can be clearer
87#![allow(clippy::bool_to_int_with_if)] // Sometimes clearer than conversion
88#![allow(clippy::single_match_else)] // Sometimes clearer than if-else
89#![allow(clippy::wildcard_imports)] // Used intentionally for enum variants
90#![allow(clippy::struct_excessive_bools)] // AutoParams struct uses bools for flags
91#![allow(clippy::missing_panics_doc)] // Would require extensive doc additions
92#![allow(clippy::similar_names)] // Variable naming style
93#![allow(clippy::option_if_let_else)] // Sometimes clearer
94#![allow(clippy::if_not_else)] // Sometimes clearer
95#![allow(clippy::useless_format)] // Sometimes needed for consistency
96#![allow(clippy::or_fun_call)] // Sometimes clearer with function call
97#![allow(clippy::unused_async)] // Placeholder for future async work
98#![allow(clippy::should_implement_trait)] // from_str intentionally different
99#![allow(clippy::needless_pass_by_value)] // Sometimes clearer API
100#![allow(clippy::manual_saturating_arithmetic)] // Explicit can be clearer
101#![allow(clippy::match_wildcard_for_single_variants)] // Sometimes clearer
102#![allow(clippy::single_char_pattern)] // Very minor optimization
103#![allow(clippy::doc_link_with_quotes)] // Documentation style choice
104#![allow(clippy::collapsible_if)] // Sometimes clearer when separate
105#![allow(clippy::map_unwrap_or)] // Sometimes clearer
106#![allow(clippy::manual_map)] // Sometimes clearer
107#![allow(clippy::default_trait_access)] // Map::default() vs Default::default()
108#![allow(clippy::implicit_saturating_sub)] // Explicit subtraction can be clearer
109#![allow(clippy::ptr_arg)] // Sometimes &Vec is clearer than &[T]
110#![allow(clippy::enum_glob_use)] // Wildcard enum imports for readability
111#![allow(clippy::unwrap_or_default)] // or_insert_with(Vec::new) style preference
112#![allow(clippy::redundant_closure)] // Sometimes clearer
113#![allow(clippy::suspicious_doc_comments)] // /// vs //! style is intentional
114#![allow(clippy::float_cmp)] // Test assertions with exact float comparison are intentional
115#![allow(clippy::large_stack_arrays)] // Test fixtures sometimes require larger arrays
116
117// Core modules
118pub mod config;
119pub mod error;
120pub mod schema;
121
122// Compilation layer
123pub mod compiler;
124
125// Execution layer
126pub mod runtime;
127
128// GraphQL parsing and query processing
129pub mod graphql;
130
131// Infrastructure
132pub mod apq;
133pub mod audit;
134pub mod cache;
135pub mod db;
136pub mod design;
137pub mod federation;
138pub mod filters;
139pub mod observability;
140pub mod security;
141pub mod tenancy;
142pub mod types;
143pub mod utils;
144pub mod validation;
145
146// Arrow Flight integration (optional)
147#[cfg(feature = "arrow")]
148pub mod arrow_executor;
149
150// Re-exports for convenience
151pub use config::FraiseQLConfig;
152pub use error::{FraiseQLError, Result};
153pub use schema::CompiledSchema;
154pub use tenancy::TenantContext;
155
156/// Version of the FraiseQL core library
157pub const VERSION: &str = env!("CARGO_PKG_VERSION");
158
159/// Minimum supported Rust version
160pub const MSRV: &str = "1.75";