[][src]Trait async_graphql::SubscriptionTransport

pub trait SubscriptionTransport: Send + Sync + Unpin + 'static {
    type Error;
    fn handle_request<Query, Mutation, Subscription>(
        &mut self,
        schema: &Schema<Query, Mutation, Subscription>,
        stubs: &mut SubscriptionStubs<Query, Mutation, Subscription>,
        data: Bytes
    ) -> Result<Option<Bytes>, Self::Error>
    where
        Query: ObjectType + Sync + Send + 'static,
        Mutation: ObjectType + Sync + Send + 'static,
        Subscription: SubscriptionType + Sync + Send + 'static
;
fn handle_response(
        &mut self,
        id: usize,
        result: 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

fn handle_request<Query, Mutation, Subscription>(
    &mut self,
    schema: &Schema<Query, Mutation, Subscription>,
    stubs: &mut SubscriptionStubs<Query, Mutation, Subscription>,
    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 request, create a SubscriptionStub with the Schema::create_subscription_stub, and then call SubscriptionStubs::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, result: 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 = String

Loading content...