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
Trait Implementations
impl<Query, Mutation, Subscription> Endpoint for GraphQLSubscription<Query, Mutation, Subscription> where
Query: ObjectType + 'static,
Mutation: ObjectType + 'static,
Subscription: SubscriptionType + 'static,
impl<Query, Mutation, Subscription> Endpoint for GraphQLSubscription<Query, Mutation, Subscription> where
Query: ObjectType + 'static,
Mutation: ObjectType + 'static,
Subscription: SubscriptionType + 'static,
Auto Trait Implementations
impl<Query, Mutation, Subscription> !RefUnwindSafe for GraphQLSubscription<Query, Mutation, Subscription>
impl<Query, Mutation, Subscription> Send for GraphQLSubscription<Query, Mutation, Subscription> where
Mutation: Send + Sync,
Query: Send + Sync,
Subscription: Send + Sync,
impl<Query, Mutation, Subscription> Sync for GraphQLSubscription<Query, Mutation, Subscription> where
Mutation: Send + Sync,
Query: Send + Sync,
Subscription: Send + Sync,
impl<Query, Mutation, Subscription> Unpin for GraphQLSubscription<Query, Mutation, Subscription>
impl<Query, Mutation, Subscription> !UnwindSafe for GraphQLSubscription<Query, Mutation, Subscription>
Blanket Implementations
Mutably borrows from an owned value. Read more
Wrap the endpoint in a Box.
fn with<T>(self, middleware: T) -> <T as Middleware<Self::Endpoint>>::Output where
T: Middleware<Self::Endpoint>,
fn with<T>(self, middleware: T) -> <T as Middleware<Self::Endpoint>>::Output where
T: Middleware<Self::Endpoint>,
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
fn and_then<F, Fut, Err, R, R2>(self, f: F) -> AndThen<Self::Endpoint, F> where
F: Fn(R) -> Fut + Send + Sync,
Fut: Future<Output = Result<R2, Err>> + Send,
Err: IntoResponse,
R: IntoResponse,
R2: IntoResponse,
Self::Endpoint: Endpoint,
Self::Endpoint: Sized,
<Self::Endpoint as Endpoint>::Output == Result<R, Err>,
fn and_then<F, Fut, Err, R, R2>(self, f: F) -> AndThen<Self::Endpoint, F> where
F: Fn(R) -> Fut + Send + Sync,
Fut: Future<Output = Result<R2, Err>> + Send,
Err: IntoResponse,
R: IntoResponse,
R2: IntoResponse,
Self::Endpoint: Endpoint,
Self::Endpoint: Sized,
<Self::Endpoint as Endpoint>::Output == Result<R, Err>,
Calls f if the result is Ok, otherwise returns the Err value of
self. Read more
Maps the response of this endpoint. Read more
fn map_err<F, Fut, InErr, OutErr, R>(self, f: F) -> MapErr<Self::Endpoint, F> where
F: Fn(InErr) -> Fut + Send + Sync,
Fut: Future<Output = OutErr> + Send,
InErr: IntoResponse,
OutErr: IntoResponse,
R: IntoResponse,
Self::Endpoint: Endpoint,
Self::Endpoint: Sized,
<Self::Endpoint as Endpoint>::Output == Result<R, InErr>,
fn map_err<F, Fut, InErr, OutErr, R>(self, f: F) -> MapErr<Self::Endpoint, F> where
F: Fn(InErr) -> Fut + Send + Sync,
Fut: Future<Output = OutErr> + Send,
InErr: IntoResponse,
OutErr: IntoResponse,
R: IntoResponse,
Self::Endpoint: Endpoint,
Self::Endpoint: Sized,
<Self::Endpoint as Endpoint>::Output == Result<R, InErr>,
Maps the error of this endpoint. Read more
type Endpoint = T
type Endpoint = T
Represents the endpoint type.
Converts this object into endpoint.
pub fn vzip(self) -> V
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