Expand description
GraphQL subscriptions using PostgreSQL LISTEN/NOTIFY.
This module provides realtime data synchronization through GraphQL subscriptions, powered by PostgreSQL’s native LISTEN/NOTIFY mechanism.
§Architecture
┌──────────────┐ WebSocket ┌──────────────┐ LISTEN/NOTIFY ┌────────────┐
│ Client │◀────────────▶│ Postrust │◀────────────────▶│ PostgreSQL│
│ (Browser) │ │ Server │ │ Database │
└──────────────┘ └──────────────┘ └────────────┘§Usage
- Create notification triggers on your tables using
broker::create_notify_trigger_sql - Start the
NotifyBrokerto listen for database notifications - Use GraphQL subscriptions to receive realtime updates
§Example
subscription {
users {
id
name
email
}
}Re-exports§
pub use broker::create_notify_trigger_sql;pub use broker::drop_notify_trigger_sql;pub use broker::table_channel_name;pub use broker::BrokerError;pub use broker::NotifyBroker;pub use broker::PgNotification;
Modules§
- broker
- PostgreSQL NOTIFY message broker for GraphQL subscriptions.
Structs§
- Subscription
Field - A subscription field in the GraphQL schema.
- Table
Change Payload - Payload structure for table change notifications.
Functions§
- generate_
subscription_ fields - Generate subscription fields for all tables in the schema.