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
//! GraphQL support for SurrealDB.
//!
//! This module implements a dynamic GraphQL schema that is generated from the
//! database's table definitions, field types, and access methods. The schema is
//! regenerated whenever the database configuration changes and cached per
//! namespace/database/config combination.
//!
//! ## Architecture
//!
//! The GraphQL subsystem is split into layers:
//!
//! - **Schema generation** ([`schema`]) -- the main entry point that orchestrates building a
//! complete `async_graphql::dynamic::Schema` from database metadata.
//! - **Table queries** ([`tables`]) -- generates Query root fields and Object types for each
//! exposed table, including field resolvers, filter/order types, nested objects, and relation
//! fields.
//! - **Mutations** ([`mutations`]) -- generates Mutation root fields (create, update, upsert,
//! delete -- single and bulk) with corresponding input types.
//! - **Functions** ([`functions`]) -- exposes user-defined database functions as Query fields.
//! - **Authentication** ([`auth`]) -- generates `signIn` / `signUp` mutations from database access
//! definitions.
//! - **Relations** ([`relations`]) -- discovers relation tables and provides data structures for
//! relation field generation.
//! - **Caching** ([`cache`]) -- caches generated schemas keyed by namespace, database, and GraphQL
//! configuration.
//! - **Error handling** ([`error`]) -- domain error type ([`GraphqlError`]) with helper
//! constructors.
//! - **Utilities** ([`utils`], [`ext`]) -- shared helpers for value conversion and `async_graphql`
//! extensions.
//!
//! The HTTP layer lives in `surrealdb-server::graphql`, which wraps the schema in an
//! Axum service.
//!
//! ## WASM
//!
//! This module is excluded from WASM targets (`#![cfg(not(target_family = "wasm"))]`)
//! because `async_graphql` and the HTTP serving stack are not compatible with WASM.
pub use *;
pub use GraphqlError;
pub use execute_request;
pub use NotificationRouter;