[−][src]Trait async_graphql::SubscriptionTransport
Subscription transport
You can customize your transport by implementing this trait.
Associated Types
type Error
The error type.
Required methods
fn handle_request<Query, Mutation, Subscription>(
&mut self,
schema: &Schema<Query, Mutation, Subscription>,
streams: &mut SubscriptionStreams,
data: Bytes
) -> Result<Option<Bytes>, Self::Error> where
Query: ObjectType + Sync + Send + 'static,
Mutation: ObjectType + Sync + Send + 'static,
Subscription: SubscriptionType + Sync + Send + 'static,
&mut self,
schema: &Schema<Query, Mutation, Subscription>,
streams: &mut SubscriptionStreams,
data: Bytes
) -> Result<Option<Bytes>, Self::Error> where
Query: ObjectType + Sync + Send + 'static,
Mutation: ObjectType + Sync + Send + 'static,
Subscription: SubscriptionType + Sync + Send + 'static,
Parse the request data here.
If you have a new subscribe, create a stream with the Schema::create_subscription_stream
, and then call SubscriptionStreams::add
.
You can return a Byte
, which will be sent to the client. If it returns an error, the connection will be broken.
fn handle_response(&mut self, id: usize, value: Value) -> Option<Bytes>
When a response message is generated, you can convert the message to the format you want here.
Implementors
impl SubscriptionTransport for WebSocketTransport
[src]
type Error = String
fn handle_request<Query, Mutation, Subscription>(
&mut self,
schema: &Schema<Query, Mutation, Subscription>,
streams: &mut SubscriptionStreams,
data: Bytes
) -> Result<Option<Bytes>, Self::Error> where
Query: ObjectType + Sync + Send + 'static,
Mutation: ObjectType + Sync + Send + 'static,
Subscription: SubscriptionType + Sync + Send + 'static,
[src]
&mut self,
schema: &Schema<Query, Mutation, Subscription>,
streams: &mut SubscriptionStreams,
data: Bytes
) -> Result<Option<Bytes>, Self::Error> where
Query: ObjectType + Sync + Send + 'static,
Mutation: ObjectType + Sync + Send + 'static,
Subscription: SubscriptionType + Sync + Send + 'static,