Function juniper_actix::subscriptions::ws_handler
source · pub async fn ws_handler<Query, Mutation, Subscription, CtxT, S, I>(
req: HttpRequest,
stream: Payload,
schema: Arc<RootNode<'static, Query, Mutation, Subscription, S>>,
init: I
) -> Result<HttpResponse, Error>where
Query: GraphQLTypeAsync<S, Context = CtxT> + Send + 'static,
Query::TypeInfo: Send + Sync,
Mutation: GraphQLTypeAsync<S, Context = CtxT> + Send + 'static,
Mutation::TypeInfo: Send + Sync,
Subscription: GraphQLSubscriptionType<S, Context = CtxT> + Send + 'static,
Subscription::TypeInfo: Send + Sync,
CtxT: Unpin + Send + Sync + 'static,
S: ScalarValue + Send + Sync + 'static,
I: Init<S, CtxT> + Send,
Expand description
Serves by auto-selecting between the
legacy graphql-ws
GraphQL over WebSocket Protocol and the
new graphql-transport-ws
GraphQL over WebSocket Protocol, based on the
Sec-Websocket-Protocol
HTTP header value.
The schema
argument is your juniper
schema.
The init
argument is used to provide the custom juniper::Context
and additional
configuration for connections. This can be a juniper_graphql_ws::ConnectionConfig
if the
context and configuration are already known, or it can be a closure that gets executed
asynchronously whenever a client sends the subscription initialization message. Using a
closure allows to perform an authentication based on the parameters provided by a client.