[][src]Trait async_graphql::SubscriptionTransport

pub trait SubscriptionTransport: Send + Sync + Unpin + 'static {
    type Error;
#[must_use]    fn handle_request<'life0, 'life1, 'life2, 'async_trait, Query, Mutation, Subscription>(
        &'life0 mut self,
        schema: &'life1 Schema<Query, Mutation, Subscription>,
        streams: &'life2 mut SubscriptionStreams,
        data: Bytes
    ) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, Self::Error>> + Send + 'async_trait>>
    where
        Query: ObjectType + Sync + Send + 'static,
        Mutation: ObjectType + Sync + Send + 'static,
        Subscription: SubscriptionType + Sync + Send + 'static,
        Query: 'async_trait,
        Mutation: 'async_trait,
        Subscription: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait,
        'life2: 'async_trait,
        Self: 'async_trait
;
fn handle_response(
        &mut self,
        id: usize,
        res: Result<Value>
    ) -> Option<Bytes>; }

Subscription transport

You can customize your transport by implementing this trait.

Associated Types

type Error

The error type.

Loading content...

Required methods

#[must_use]fn handle_request<'life0, 'life1, 'life2, 'async_trait, Query, Mutation, Subscription>(
    &'life0 mut self,
    schema: &'life1 Schema<Query, Mutation, Subscription>,
    streams: &'life2 mut SubscriptionStreams,
    data: Bytes
) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, Self::Error>> + Send + 'async_trait>> where
    Query: ObjectType + Sync + Send + 'static,
    Mutation: ObjectType + Sync + Send + 'static,
    Subscription: SubscriptionType + Sync + Send + 'static,
    Query: 'async_trait,
    Mutation: 'async_trait,
    Subscription: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 

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, res: Result<Value>) -> Option<Bytes>

When a response message is generated, you can convert the message to the format you want here.

Loading content...

Implementors

impl SubscriptionTransport for WebSocketTransport[src]

type Error = FieldError

Loading content...