Struct diana::DianaHandler [−][src]
pub struct DianaHandler<C, Q, M, S> where
C: Any + Send + Sync + Clone,
Q: Clone + ObjectType + 'static,
M: Clone + ObjectType + 'static,
S: Clone + SubscriptionType + 'static, { pub opts: Options<C, Q, M, S>, pub schema_without_subscriptions: Schema<Q, M, EmptySubscription>, pub schema_for_subscriptions: Schema<SubscriptionQuery, PublishMutation, S>, }
Expand description
The core logic primitive that underlies Diana’s systems. You should only use this if you need to support a platform other than the ones Diana has pre-built systems for (see the book). This is a struct so as to allow the caching of data that stay the same across requests, like the parsed and built schemas.
Fields
opts: Options<C, Q, M, S>
The options parsed in to the handler in ::new()
.You should only need to touch this if you’re building a custom integration.
schema_without_subscriptions: Schema<Q, M, EmptySubscription>
The schema created for the queries/mutations system. This has the user’s given query and mutation roots and no subscriptions at all. You should only need to touch this if you’re building a custom integration.
schema_for_subscriptions: Schema<SubscriptionQuery, PublishMutation, S>
The schema created for the subscriptions server. This has the user’s given subscription root and internally used query/mutation roots for communication with the query/mutation system. You should only need to touch this if you’re building a custom integration.
Implementations
impl<C, Q, M, S> DianaHandler<C, Q, M, S> where
C: Any + Send + Sync + Clone,
Q: Clone + ObjectType + 'static,
M: Clone + ObjectType + 'static,
S: Clone + SubscriptionType + 'static,
impl<C, Q, M, S> DianaHandler<C, Q, M, S> where
C: Any + Send + Sync + Clone,
Q: Clone + ObjectType + 'static,
M: Clone + ObjectType + 'static,
S: Clone + SubscriptionType + 'static,
Creates a new instance of the handler with the given options.
Determines ahead of time whether or not a request is authenticated. This should be used in middleware if possible so we can avoid
sending full payloads if the auth token isn’t even valid.
This just takes the HTTP Authorization
header and returns an AuthVerdict
.
pub async fn run_stateless_for_subscriptions<A: Into<String> + Display>(
&self,
body: String,
raw_auth_header: Option<A>,
given_auth_verdict: Option<AuthVerdict>
) -> DianaResponse
pub async fn run_stateless_for_subscriptions<A: Into<String> + Display>(
&self,
body: String,
raw_auth_header: Option<A>,
given_auth_verdict: Option<AuthVerdict>
) -> DianaResponse
Runs a query or mutation (stateless) given the request body and the value of the HTTP Authorization
header.
This performs authorisation checks and runs the actual request. If you’ve already used .is_authed()
to obtain an AuthVerdict
,
this can be provided as the third argument to avoid running auth checks twice.
This will return a DianaResponse
no matter what, which simplifies error handling significantly.
This function is for the subscriptions system only.
pub async fn run_stateless_without_subscriptions<A: Into<String> + Display>(
&self,
body: String,
raw_auth_header: Option<A>,
given_auth_verdict: Option<AuthVerdict>
) -> DianaResponse
pub async fn run_stateless_without_subscriptions<A: Into<String> + Display>(
&self,
body: String,
raw_auth_header: Option<A>,
given_auth_verdict: Option<AuthVerdict>
) -> DianaResponse
Runs a query or mutation (stateless) given the request body and the value of the HTTP Authorization
header.
This performs authorisation checks and runs the actual request. If you’ve already used .is_authed()
to obtain an AuthVerdict
,
this can be provided as the third argument to avoid running auth checks twice.
This will return a DianaResponse
no matter what, which simplifies error handling significantly.
This function is for the queries/mutations system only.
Trait Implementations
impl<C: Clone, Q: Clone, M: Clone, S: Clone> Clone for DianaHandler<C, Q, M, S> where
C: Any + Send + Sync + Clone,
Q: Clone + ObjectType + 'static,
M: Clone + ObjectType + 'static,
S: Clone + SubscriptionType + 'static,
impl<C: Clone, Q: Clone, M: Clone, S: Clone> Clone for DianaHandler<C, Q, M, S> where
C: Any + Send + Sync + Clone,
Q: Clone + ObjectType + 'static,
M: Clone + ObjectType + 'static,
S: Clone + SubscriptionType + 'static,
Auto Trait Implementations
impl<C, Q, M, S> !RefUnwindSafe for DianaHandler<C, Q, M, S>
impl<C, Q, M, S> Send for DianaHandler<C, Q, M, S>
impl<C, Q, M, S> Sync for DianaHandler<C, Q, M, S>
impl<C, Q, M, S> !UnwindSafe for DianaHandler<C, Q, M, S>
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more