pub struct GraphQLSubscription<Query, Mutation, Subscription> { /* private fields */ }
Expand description

A GraphQL subscription endpoint.

Example

use async_graphql::{EmptyMutation, Object, Schema, Subscription};
use async_graphql_poem::GraphQLSubscription;
use futures_util::{stream, Stream};
use poem::{get, Route};

struct Query;

#[Object]
impl Query {
    async fn value(&self) -> i32 {
        100
    }
}

struct Subscription;

#[Subscription]
impl Subscription {
    async fn values(&self) -> impl Stream<Item = i32> {
        stream::iter(vec![1, 2, 3, 4, 5])
    }
}

type MySchema = Schema<Query, EmptyMutation, Subscription>;

let schema = Schema::new(Query, EmptyMutation, Subscription);
let app = Route::new().at("/ws", get(GraphQLSubscription::new(schema)));

Implementations

Create a GraphQL subscription endpoint.

Trait Implementations

Represents the response of the endpoint.

Get the response to the request.

Get the response to the request and return a Response. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Wrap the endpoint in a Box.

Use middleware to transform this endpoint. Read more

if enable is true then use middleware to transform this endpoint. Read more

Attach a state data to the endpoint, similar to with(AddData(T)). Read more

if data is Some(T) then attach the value to the endpoint.

Maps the request of this endpoint. Read more

Maps the output of this endpoint. Read more

Maps the request and response of this endpoint. Read more

Convert the output of this endpoint into a response. Response. Read more

Convert the output of this endpoint into a response. Response. Read more

Maps the response of this endpoint. Read more

Calls f if the result is Ok, otherwise returns the Err value of self. Read more

Catch all errors and convert it into a response. Read more

Catch the specified type of error and convert it into a response. Read more

Does something with each error. Read more

Does something with each specified error type. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Represents the endpoint type.

Converts this object into endpoint.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more