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