pub struct GraphQLState {
pub pool: PgPool,
pub schema_cache: Arc<SchemaCache>,
pub generated_schema: GeneratedSchema,
pub schema: Schema,
pub config: SchemaConfig,
pub subscription_fields: Vec<SubscriptionField>,
pub broker: Arc<RwLock<Option<NotifyBroker>>>,
}Expand description
GraphQL execution state shared across requests.
Fields§
§pool: PgPoolDatabase connection pool
schema_cache: Arc<SchemaCache>Schema cache
generated_schema: GeneratedSchemaGenerated GraphQL schema
schema: Schemaasync-graphql Schema (built dynamically)
config: SchemaConfigSchema configuration
subscription_fields: Vec<SubscriptionField>Subscription fields
broker: Arc<RwLock<Option<NotifyBroker>>>Notification broker for subscriptions
Implementations§
Source§impl GraphQLState
impl GraphQLState
Sourcepub fn new(
pool: PgPool,
schema_cache: Arc<SchemaCache>,
config: SchemaConfig,
) -> Result<Self, GraphQLError>
pub fn new( pool: PgPool, schema_cache: Arc<SchemaCache>, config: SchemaConfig, ) -> Result<Self, GraphQLError>
Create new GraphQL state from schema cache.
Sourcepub fn rebuild(&mut self) -> Result<(), GraphQLError>
pub fn rebuild(&mut self) -> Result<(), GraphQLError>
Rebuild the schema (e.g., after schema cache refresh).
Sourcepub async fn init_subscriptions(&self) -> Result<(), BrokerError>
pub async fn init_subscriptions(&self) -> Result<(), BrokerError>
Initialize the subscription broker.
This should be called after creating the state to enable subscriptions.
Sourcepub async fn stop_subscriptions(&self)
pub async fn stop_subscriptions(&self)
Stop the subscription broker.
Sourcepub async fn get_broker(&self) -> Option<Arc<RwLock<Option<NotifyBroker>>>>
pub async fn get_broker(&self) -> Option<Arc<RwLock<Option<NotifyBroker>>>>
Get the notification broker.
Auto Trait Implementations§
impl Freeze for GraphQLState
impl !RefUnwindSafe for GraphQLState
impl Send for GraphQLState
impl Sync for GraphQLState
impl Unpin for GraphQLState
impl !UnwindSafe for GraphQLState
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 more