Struct async_graphql_axum::GraphQLWebSocket
source · pub struct GraphQLWebSocket<Sink, Stream, E, OnConnInit> { /* private fields */ }
Expand description
A Websocket connection for GraphQL subscription.
Implementations§
source§impl<S, E> GraphQLWebSocket<SplitSink<S, Message>, SplitStream<S>, E, fn(_: Value) -> Ready<Result<Data>>>where
S: Stream<Item = Result<Message, Error>> + Sink<Message>,
E: Executor,
impl<S, E> GraphQLWebSocket<SplitSink<S, Message>, SplitStream<S>, E, fn(_: Value) -> Ready<Result<Data>>>where
S: Stream<Item = Result<Message, Error>> + Sink<Message>,
E: Executor,
sourcepub fn new(stream: S, executor: E, protocol: GraphQLProtocol) -> Self
pub fn new(stream: S, executor: E, protocol: GraphQLProtocol) -> Self
Create a GraphQLWebSocket
object.
source§impl<Sink, Stream, E> GraphQLWebSocket<Sink, Stream, E, fn(_: Value) -> Ready<Result<Data>>>where
Sink: Sink<Message>,
Stream: Stream<Item = Result<Message, Error>>,
E: Executor,
impl<Sink, Stream, E> GraphQLWebSocket<Sink, Stream, E, fn(_: Value) -> Ready<Result<Data>>>where
Sink: Sink<Message>,
Stream: Stream<Item = Result<Message, Error>>,
E: Executor,
sourcepub fn new_with_pair(
sink: Sink,
stream: Stream,
executor: E,
protocol: GraphQLProtocol
) -> Self
pub fn new_with_pair(
sink: Sink,
stream: Stream,
executor: E,
protocol: GraphQLProtocol
) -> Self
Create a GraphQLWebSocket
object with sink and stream objects.
source§impl<Sink, Stream, E, OnConnInit, OnConnInitFut> GraphQLWebSocket<Sink, Stream, E, OnConnInit>where
Sink: Sink<Message>,
Stream: Stream<Item = Result<Message, Error>>,
E: Executor,
OnConnInit: FnOnce(Value) -> OnConnInitFut + Send + 'static,
OnConnInitFut: Future<Output = Result<Data>> + Send + 'static,
impl<Sink, Stream, E, OnConnInit, OnConnInitFut> GraphQLWebSocket<Sink, Stream, E, OnConnInit>where
Sink: Sink<Message>,
Stream: Stream<Item = Result<Message, Error>>,
E: Executor,
OnConnInit: FnOnce(Value) -> OnConnInitFut + Send + 'static,
OnConnInitFut: Future<Output = Result<Data>> + Send + 'static,
sourcepub fn with_data(self, data: Data) -> Self
pub fn with_data(self, data: Data) -> Self
Specify the initial subscription context data, usually you can get something from the incoming request to create it.
sourcepub fn on_connection_init<OnConnInit2, Fut>(
self,
callback: OnConnInit2
) -> GraphQLWebSocket<Sink, Stream, E, OnConnInit2>where
OnConnInit2: FnOnce(Value) -> Fut + Send + 'static,
Fut: Future<Output = Result<Data>> + Send + 'static,
pub fn on_connection_init<OnConnInit2, Fut>(
self,
callback: OnConnInit2
) -> GraphQLWebSocket<Sink, Stream, E, OnConnInit2>where
OnConnInit2: FnOnce(Value) -> Fut + Send + 'static,
Fut: Future<Output = Result<Data>> + Send + 'static,
Specify a callback function to be called when the connection is initialized.
You can get something from the payload of GQL_CONNECTION_INIT
message to create Data
.
The data returned by this callback function will be merged with the data
specified by [with_data
].