pub struct ServerConfig {Show 35 fields
pub schema_path: PathBuf,
pub database_url: String,
pub bind_addr: SocketAddr,
pub cors_enabled: bool,
pub cors_origins: Vec<String>,
pub compression_enabled: bool,
pub tracing_enabled: bool,
pub apq_enabled: bool,
pub cache_enabled: bool,
pub graphql_path: String,
pub health_path: String,
pub introspection_path: String,
pub metrics_path: String,
pub metrics_json_path: String,
pub playground_path: String,
pub playground_enabled: bool,
pub playground_tool: PlaygroundTool,
pub subscription_path: String,
pub subscriptions_enabled: bool,
pub metrics_enabled: bool,
pub metrics_token: Option<String>,
pub admin_api_enabled: bool,
pub admin_token: Option<String>,
pub introspection_enabled: bool,
pub introspection_require_auth: bool,
pub design_api_require_auth: bool,
pub pool_min_size: usize,
pub pool_max_size: usize,
pub pool_timeout_secs: u64,
pub auth: Option<OidcConfig>,
pub tls: Option<TlsServerConfig>,
pub database_tls: Option<DatabaseTlsConfig>,
pub require_json_content_type: bool,
pub max_request_body_bytes: usize,
pub rate_limiting: Option<RateLimitingConfig>,
}Expand description
Server configuration.
Fields§
§schema_path: PathBufPath to compiled schema JSON file.
database_url: StringDatabase connection URL (PostgreSQL, MySQL, SQLite, SQL Server).
bind_addr: SocketAddrServer bind address.
cors_enabled: boolEnable CORS.
cors_origins: Vec<String>CORS allowed origins (if empty, allows all).
compression_enabled: boolEnable compression.
tracing_enabled: boolEnable request tracing.
apq_enabled: boolEnable APQ (Automatic Persisted Queries).
cache_enabled: boolEnable query caching.
graphql_path: StringGraphQL endpoint path.
health_path: StringHealth check endpoint path.
introspection_path: StringIntrospection endpoint path.
metrics_path: StringMetrics endpoint path (Prometheus format).
metrics_json_path: StringMetrics JSON endpoint path.
playground_path: StringPlayground (GraphQL IDE) endpoint path.
playground_enabled: boolEnable GraphQL playground/IDE (default: false for production safety).
When enabled, serves a GraphQL IDE (GraphiQL or Apollo Sandbox)
at the configured playground_path.
Security: Disabled by default for production safety. Set to true for development environments only. The playground exposes schema information and can be a reconnaissance vector for attackers.
playground_tool: PlaygroundToolWhich GraphQL IDE to use.
graphiql: The classic GraphQL IDE (default)apollo-sandbox: Apollo’s embeddable sandbox
subscription_path: StringWebSocket endpoint path for GraphQL subscriptions.
subscriptions_enabled: boolEnable GraphQL subscriptions over WebSocket.
When enabled, provides graphql-ws (graphql-transport-ws) protocol support for real-time subscription events.
metrics_enabled: boolEnable metrics endpoints.
Security: Disabled by default for production safety.
When enabled, requires metrics_token to be set for authentication.
metrics_token: Option<String>Bearer token for metrics endpoint authentication.
Required when metrics_enabled is true. Requests must include:
Authorization: Bearer <token>
Security: Use a strong, random token (e.g., 32+ characters).
admin_api_enabled: boolEnable admin API endpoints (default: false for production safety).
Security: Disabled by default. When enabled, requires admin_token to be set.
Admin endpoints allow schema reloading, cache management, and config inspection.
admin_token: Option<String>Bearer token for admin API authentication.
Required when admin_api_enabled is true. Requests must include:
Authorization: Bearer <token>
Security: Use a strong, random token (minimum 32 characters). This token grants access to sensitive operations like schema reloading.
introspection_enabled: boolEnable introspection endpoint (default: false for production safety).
Security: Disabled by default. When enabled, the introspection endpoint
exposes the complete GraphQL schema structure. Combined with introspection_require_auth,
you can optionally protect it with OIDC authentication.
introspection_require_auth: boolRequire authentication for introspection endpoint (default: true).
When true and OIDC is configured, introspection requires same auth as GraphQL endpoint. When false, introspection is publicly accessible (use only in development).
design_api_require_auth: boolRequire authentication for design audit API endpoints (default: true).
Design audit endpoints expose system architecture and optimization opportunities. When true and OIDC is configured, design endpoints require same auth as GraphQL endpoint. When false, design endpoints are publicly accessible (use only in development).
pool_min_size: usizeDatabase connection pool minimum size.
pool_max_size: usizeDatabase connection pool maximum size.
pool_timeout_secs: u64Database connection pool timeout in seconds.
auth: Option<OidcConfig>OIDC authentication configuration (optional).
When set, enables JWT authentication using OIDC discovery. Supports Auth0, Keycloak, Okta, Cognito, Azure AD, and any OIDC-compliant provider.
§Example (TOML)
[auth]
issuer = "https://your-tenant.auth0.com/"
audience = "your-api-identifier"tls: Option<TlsServerConfig>TLS/SSL configuration for HTTPS and encrypted connections.
When set, enables TLS enforcement for HTTP/gRPC endpoints and optionally requires mutual TLS (mTLS) for client certificates.
§Example (TOML)
[tls]
enabled = true
cert_path = "/etc/fraiseql/cert.pem"
key_path = "/etc/fraiseql/key.pem"
require_client_cert = false
min_version = "1.2" # "1.2" or "1.3"database_tls: Option<DatabaseTlsConfig>Database TLS configuration.
Enables TLS for database connections and configures per-database TLS settings (PostgreSQL, Redis, ClickHouse, etc.).
§Example (TOML)
[database_tls]
postgres_ssl_mode = "require" # disable, allow, prefer, require, verify-ca, verify-full
redis_ssl = true # Use rediss:// protocol
clickhouse_https = true # Use HTTPS
elasticsearch_https = true # Use HTTPS
verify_certificates = true # Verify server certificatesrequire_json_content_type: boolRequire Content-Type: application/json on POST requests (default: true).
CSRF protection: rejects POST requests with non-JSON Content-Type
(e.g. text/plain, application/x-www-form-urlencoded) with 415.
max_request_body_bytes: usizeMaximum request body size in bytes (default: 1 MB).
Requests exceeding this limit receive 413 Payload Too Large. Set to 0 to use axum’s default (no limit).
rate_limiting: Option<RateLimitingConfig>Rate limiting configuration for GraphQL requests.
When configured, enables per-IP and per-user rate limiting with token bucket algorithm. Defaults to enabled with sensible per-IP limits for security-by-default.
§Example (TOML)
[rate_limiting]
enabled = true
rps_per_ip = 100 # 100 requests/second per IP
rps_per_user = 1000 # 1000 requests/second per authenticated user
burst_size = 500 # Allow bursts up to 500 requestsImplementations§
Source§impl ServerConfig
impl ServerConfig
Sourcepub fn is_production_mode() -> bool
pub fn is_production_mode() -> bool
Check if running in production mode.
Production mode is detected via FRAISEQL_ENV environment variable.
productionorprod(or any value other thandevelopment/dev) → production modedevelopmentordev→ development mode
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validate configuration.
§Errors
Returns error if:
metrics_enabledis true butmetrics_tokenis not setmetrics_tokenis set but too short (< 16 characters)authconfig is set but invalid (e.g., empty issuer)tlsis enabled but cert or key path is missing- TLS minimum version is invalid
- In production mode:
playground_enabledis true - In production mode:
cors_enabledis true butcors_originsis empty
Sourcepub fn auth_enabled(&self) -> bool
pub fn auth_enabled(&self) -> bool
Check if authentication is enabled.
Trait Implementations§
Source§impl Clone for ServerConfig
impl Clone for ServerConfig
Source§fn clone(&self) -> ServerConfig
fn clone(&self) -> ServerConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ServerConfig
impl Debug for ServerConfig
Source§impl Default for ServerConfig
impl Default for ServerConfig
Source§impl<'de> Deserialize<'de> for ServerConfig
impl<'de> Deserialize<'de> for ServerConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for ServerConfig
impl RefUnwindSafe for ServerConfig
impl Send for ServerConfig
impl Sync for ServerConfig
impl Unpin for ServerConfig
impl UnsafeUnpin for ServerConfig
impl UnwindSafe for ServerConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().