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//! ## Architecture
6//!
7//! FraiseQL v2 compiles GraphQL schemas into optimized SQL execution plans at build time,
8//! eliminating runtime overhead and enabling deterministic, high-performance query execution.
9//!
10//! ### Key Components
11//!
12//! - **Schema**: Compiled schema representation (types, fields, SQL mappings)
13//! - **Compiler**: Parsing, validation, and runtime sub-modules (aggregation, fact tables, window
14//!   functions)
15//! - **Runtime**: Compiled query executor
16//! - **Database**: Connection pooling and transaction management
17//! - **Cache**: Query result caching with coherency
18//! - **Security**: Authentication, authorization, and audit
19//! - **APQ**: Automatic Persisted Queries
20//!
21//! ## Compilation Flow
22//!
23//! ```text
24//! Python/TypeScript Decorators
25//!         ↓
26//!    JSON Schema
27//!         ↓
28//!  SchemaConverter (fraiseql-cli)
29//!    ↙    ↓    ↘
30//! Parse Validate Convert
31//!         ↓
32//!  CompiledSchema.json
33//!         ↓
34//!      Runtime
35//!    ↙    ↓    ↘
36//! Match Execute Project
37//!         ↓
38//!   GraphQL Response
39//! ```
40//!
41//! ## Example
42//!
43//! ```no_run
44//! // Requires: a compiled schema file and a live PostgreSQL database.
45//! // See: tests/integration/ for runnable examples.
46//! use fraiseql_core::schema::CompiledSchema;
47//! use fraiseql_core::runtime::Executor;
48//! use fraiseql_core::db::postgres::PostgresAdapter;
49//! use std::sync::Arc;
50//!
51//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
52//! # let schema_json = r#"{"types":[],"queries":[]}"#;
53//! // Load compiled schema
54//! let schema = CompiledSchema::from_json(schema_json)?;
55//!
56//! // Create executor (db_pool is a DatabaseAdapter implementation)
57//! let db_pool = Arc::new(PostgresAdapter::new("postgresql://localhost/mydb").await?);
58//! let executor = Executor::new(schema, db_pool);
59//!
60//! // Execute query
61//! let query = r#"query { users { id name } }"#;
62//! let result = executor.execute(query, None).await?;
63//!
64//! println!("{}", result);
65//! # Ok(())
66//! # }
67//! ```
68
69#![forbid(unsafe_code)]
70
71// Core modules
72pub mod config;
73pub mod error;
74pub mod http;
75pub mod schema;
76
77// Compilation layer
78pub mod compiler;
79
80// Execution layer
81pub mod runtime;
82
83// GraphQL parsing and query processing
84pub mod graphql;
85
86// Infrastructure
87pub mod apq;
88pub mod cache;
89pub use fraiseql_db as db;
90#[cfg(feature = "schema-lint")]
91pub mod design;
92#[cfg(feature = "federation")]
93pub use fraiseql_federation as federation;
94pub mod filters;
95pub mod security;
96pub mod tenancy;
97pub mod types;
98pub mod utils;
99pub mod validation;
100
101pub mod prelude;
102
103// Re-exports for convenience
104pub use config::FraiseQLConfig;
105pub use error::{FraiseQLError, Result};
106pub use schema::CompiledSchema;
107pub use tenancy::TenantContext;
108
109/// Version of the FraiseQL core library
110pub const VERSION: &str = env!("CARGO_PKG_VERSION");
111
112/// Minimum supported Rust version
113pub const MSRV: &str = "1.88";