Struct async_graphql_poem::GraphQLSubscription[][src]

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

A GraphQL subscription endpoint.

Example

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

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.

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

A helper function, similar to with(AddData(T)). Read more

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 result Result<Response>. Response. Read more

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

Maps the response of this endpoint. Read more

Maps the error of this endpoint. Read more

Performs the conversion.

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

Performs the conversion.

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