pub struct Server<A: DatabaseAdapter> { /* private fields */ }Expand description
FraiseQL HTTP Server.
Implementations§
Source§impl<A: DatabaseAdapter + Clone + Send + Sync + 'static> Server<A>
impl<A: DatabaseAdapter + Clone + Send + Sync + 'static> Server<A>
Sourcepub async fn new(
config: ServerConfig,
schema: CompiledSchema,
adapter: Arc<A>,
db_pool: Option<PgPool>,
) -> Result<Self>
pub async fn new( config: ServerConfig, schema: CompiledSchema, adapter: Arc<A>, db_pool: Option<PgPool>, ) -> Result<Self>
Create new server.
Relay pagination queries will return a Validation error at runtime. Use
Server::with_relay_pagination when the adapter implements RelayDatabaseAdapter
and relay support is required.
§Arguments
config- Server configurationschema- Compiled GraphQL schemaadapter- Database adapterdb_pool- Database connection pool (optional, required for observers)
§Errors
Returns error if OIDC validator initialization fails (e.g., unable to fetch discovery document or JWKS).
§Example
let config = ServerConfig::default();
let schema = CompiledSchema::from_json(schema_json)?;
let adapter = Arc::new(PostgresAdapter::new(db_url).await?);
let server = Server::new(config, schema, adapter, None).await?;
server.serve().await?;Sourcepub fn with_subscription_lifecycle(
self,
lifecycle: Arc<dyn SubscriptionLifecycle>,
) -> Self
pub fn with_subscription_lifecycle( self, lifecycle: Arc<dyn SubscriptionLifecycle>, ) -> Self
Set lifecycle hooks for WebSocket subscriptions.
Sourcepub fn with_max_subscriptions_per_connection(self, max: u32) -> Self
pub fn with_max_subscriptions_per_connection(self, max: u32) -> Self
Set maximum subscriptions allowed per WebSocket connection.
Sourcepub fn set_secrets_manager(&mut self, manager: Arc<SecretsManager>)
pub fn set_secrets_manager(&mut self, manager: Arc<SecretsManager>)
Set secrets manager for the server.
This allows attaching a secrets manager after server creation for credential management.
Source§impl<A: DatabaseAdapter + RelayDatabaseAdapter + Clone + Send + Sync + 'static> Server<A>
impl<A: DatabaseAdapter + RelayDatabaseAdapter + Clone + Send + Sync + 'static> Server<A>
Sourcepub async fn with_relay_pagination(
config: ServerConfig,
schema: CompiledSchema,
adapter: Arc<A>,
db_pool: Option<PgPool>,
) -> Result<Self>
pub async fn with_relay_pagination( config: ServerConfig, schema: CompiledSchema, adapter: Arc<A>, db_pool: Option<PgPool>, ) -> Result<Self>
Create a server with relay pagination support enabled.
The adapter must implement RelayDatabaseAdapter. Currently, only
PostgresAdapter and CachedDatabaseAdapter<PostgresAdapter> satisfy this bound.
Relay queries issued against a server created with Server::new return a
Validation error at runtime; those issued against a server created with this
constructor succeed.
§Arguments
config- Server configurationschema- Compiled GraphQL schemaadapter- Database adapter (must implementRelayDatabaseAdapter)db_pool- Database connection pool (optional, required for observers)
§Errors
Returns error if OIDC validator initialization fails.
§Example
let adapter = Arc::new(PostgresAdapter::new(db_url).await?);
let server = Server::with_relay_pagination(config, schema, adapter, None).await?;
server.serve().await?;Source§impl<A: DatabaseAdapter + Clone + Send + Sync + 'static> Server<A>
impl<A: DatabaseAdapter + Clone + Send + Sync + 'static> Server<A>
Sourcepub async fn serve(self) -> Result<()>
pub async fn serve(self) -> Result<()>
Start server and listen for requests.
§Errors
Returns error if server fails to bind or encounters runtime errors.
Sourcepub async fn serve_with_shutdown<F>(self, shutdown: F) -> Result<()>
pub async fn serve_with_shutdown<F>(self, shutdown: F) -> Result<()>
Start server with a custom shutdown future.
Enables programmatic shutdown (e.g., for --watch hot-reload) by accepting any
future that resolves when the server should stop.
§Errors
Returns error if server fails to bind or encounters runtime errors.
Sourcepub async fn shutdown_signal()
pub async fn shutdown_signal()
Listen for shutdown signals (Ctrl+C or SIGTERM)
Auto Trait Implementations§
impl<A> Freeze for Server<A>
impl<A> !RefUnwindSafe for Server<A>
impl<A> Send for Server<A>
impl<A> Sync for Server<A>
impl<A> Unpin for Server<A>
impl<A> UnsafeUnpin for Server<A>
impl<A> !UnwindSafe for Server<A>
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> 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::Request