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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//! # Turbograph
//!
//! PostGraphile-style GraphQL API generation for PostgreSQL, built in Rust.
//!
//! Turbograph introspects your PostgreSQL schema and automatically builds a
//! full-featured [`async_graphql`] schema with:
//!
//! - **Queries** — paginated `allXxx` root fields with filtering, ordering, and
//! cursor-based pagination.
//! - **Mutations** — `createXxx`, `updateXxx`, and `deleteXxx` root fields.
//! - **Per-request transaction settings** — inject a [`TransactionConfig`] into
//! the GraphQL context to set the role, isolation level, timeouts, and
//! arbitrary `SET LOCAL` variables for row-level security.
//! - **Live schema reloading** — when `watch_pg` is enabled, the schema is
//! automatically rebuilt whenever DDL changes are detected.
//!
//! ## Quick start
//!
//! ```rust,no_run
//! use turbograph::{Config, PoolConfig, TurboGraph};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
//! let graph = TurboGraph::new(Config {
//! pool: PoolConfig::ConnectionString(
//! "postgres://user:pass@localhost:5432/mydb".into(),
//! ),
//! schemas: vec!["public".into()],
//! watch_pg: false,
//! })
//! .await?;
//!
//! // Execute a GraphQL request
//! let response = graph
//! .execute(async_graphql::Request::new("{ __typename }"))
//! .await;
//! println!("{:?}", response);
//! Ok(())
//! }
//! ```
//!
//! For a complete HTTP server example using Axum, see the
//! `examples/server` directory in the repository.
pub use DbError;
pub use *;
pub use ;
pub use TurboGraph;
/// Convenience wrapper around [`TurboGraph::new`].
///
/// Builds the GraphQL schema by introspecting the database described by
/// `config`. Identical to calling `TurboGraph::new(config).await`.
///
/// # Errors
///
/// Returns an error if the database cannot be reached, the pool cannot be
/// created, or schema introspection fails.
///
/// # Example
///
/// ```rust,no_run
/// use turbograph::{build_schema, Config, PoolConfig};
///
/// #[tokio::main]
/// async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
/// let graph = build_schema(Config {
/// pool: PoolConfig::ConnectionString(
/// "postgres://user:pass@localhost:5432/mydb".into(),
/// ),
/// schemas: vec!["public".into()],
/// watch_pg: false,
/// })
/// .await?;
/// Ok(())
/// }
/// ```
pub async