Struct async_graphql_poem::GraphQLSubscription
source · pub struct GraphQLSubscription<E> { /* 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§
source§impl<E> GraphQLSubscription<E>
impl<E> GraphQLSubscription<E>
Trait Implementations§
Auto Trait Implementations§
impl<E> RefUnwindSafe for GraphQLSubscription<E>where
E: RefUnwindSafe,
impl<E> Send for GraphQLSubscription<E>where
E: Send,
impl<E> Sync for GraphQLSubscription<E>where
E: Sync,
impl<E> Unpin for GraphQLSubscription<E>where
E: Unpin,
impl<E> UnwindSafe for GraphQLSubscription<E>where
E: UnwindSafe,
Blanket Implementations§
source§impl<T> EndpointExt for Twhere
T: IntoEndpoint,
impl<T> EndpointExt for Twhere
T: IntoEndpoint,
source§fn boxed<'a>(
self
) -> Box<dyn Endpoint<Output = <Self::Endpoint as Endpoint>::Output> + 'a, Global>where
Self: 'a + Sized,
fn boxed<'a>(
self
) -> Box<dyn Endpoint<Output = <Self::Endpoint as Endpoint>::Output> + 'a, Global>where
Self: 'a + Sized,
Wrap the endpoint in a Box.
source§fn with<T>(self, middleware: T) -> <T as Middleware<Self::Endpoint>>::Outputwhere
T: Middleware<Self::Endpoint>,
Self: Sized,
fn with<T>(self, middleware: T) -> <T as Middleware<Self::Endpoint>>::Outputwhere
T: Middleware<Self::Endpoint>,
Self: Sized,
Use middleware to transform this endpoint. Read more
source§fn with_if<T>(
self,
enable: bool,
middleware: T
) -> EitherEndpoint<Self, <T as Middleware<Self::Endpoint>>::Output>where
T: Middleware<Self::Endpoint>,
Self: Sized,
fn with_if<T>(
self,
enable: bool,
middleware: T
) -> EitherEndpoint<Self, <T as Middleware<Self::Endpoint>>::Output>where
T: Middleware<Self::Endpoint>,
Self: Sized,
source§fn data<T>(self, data: T) -> AddDataEndpoint<Self::Endpoint, T>where
T: 'static + Clone + Send + Sync,
Self: Sized,
fn data<T>(self, data: T) -> AddDataEndpoint<Self::Endpoint, T>where
T: 'static + Clone + Send + Sync,
Self: Sized,
Attach a state data to the endpoint, similar to
with(AddData(T)). Read moresource§fn data_opt<T>(
self,
data: Option<T>
) -> EitherEndpoint<AddDataEndpoint<Self::Endpoint, T>, Self>where
T: 'static + Clone + Send + Sync,
Self: Sized,
fn data_opt<T>(
self,
data: Option<T>
) -> EitherEndpoint<AddDataEndpoint<Self::Endpoint, T>, Self>where
T: 'static + Clone + Send + Sync,
Self: Sized,
if
data is Some(T) then attach the value to the endpoint.source§fn before<F, Fut>(self, f: F) -> Before<Self, F>where
F: Fn(Request) -> Fut + Send + Sync,
Fut: Future<Output = Result<Request, Error>> + Send,
Self: Sized,
fn before<F, Fut>(self, f: F) -> Before<Self, F>where
F: Fn(Request) -> Fut + Send + Sync,
Fut: Future<Output = Result<Request, Error>> + Send,
Self: Sized,
Maps the request of this endpoint. Read more
source§fn after<F, Fut, T>(self, f: F) -> After<Self::Endpoint, F>where
F: Fn(Result<<Self::Endpoint as Endpoint>::Output, Error>) -> Fut + Send + Sync,
Fut: Future<Output = Result<T, Error>> + Send,
T: IntoResponse,
Self: Sized,
fn after<F, Fut, T>(self, f: F) -> After<Self::Endpoint, F>where
F: Fn(Result<<Self::Endpoint as Endpoint>::Output, Error>) -> Fut + Send + Sync,
Fut: Future<Output = Result<T, Error>> + Send,
T: IntoResponse,
Self: Sized,
Maps the output of this endpoint. Read more
source§fn around<F, Fut, R>(self, f: F) -> Around<Self::Endpoint, F>where
F: 'static + Fn(Arc<Self::Endpoint>, Request) -> Fut + Send + Sync,
Fut: 'static + Future<Output = Result<R, Error>> + Send,
R: IntoResponse,
Self: Sized,
fn around<F, Fut, R>(self, f: F) -> Around<Self::Endpoint, F>where
F: 'static + Fn(Arc<Self::Endpoint>, Request) -> Fut + Send + Sync,
Fut: 'static + Future<Output = Result<R, Error>> + Send,
R: IntoResponse,
Self: Sized,
Maps the request and response of this endpoint. Read more
source§fn map_to_response(self) -> MapToResponse<Self::Endpoint>where
Self: Sized,
fn map_to_response(self) -> MapToResponse<Self::Endpoint>where
Self: Sized,
source§fn to_response(self) -> ToResponse<Self::Endpoint>where
Self: Sized,
fn to_response(self) -> ToResponse<Self::Endpoint>where
Self: Sized,
source§fn map<F, Fut, R, R2>(self, f: F) -> Map<Self::Endpoint, F>where
F: Fn(R) -> Fut + Send + Sync,
Fut: Future<Output = R2> + Send,
R: IntoResponse,
R2: IntoResponse,
Self: Sized,
Self::Endpoint: Endpoint<Output = R> + Sized,
fn map<F, Fut, R, R2>(self, f: F) -> Map<Self::Endpoint, F>where
F: Fn(R) -> Fut + Send + Sync,
Fut: Future<Output = R2> + Send,
R: IntoResponse,
R2: IntoResponse,
Self: Sized,
Self::Endpoint: Endpoint<Output = R> + Sized,
Maps the response of this endpoint. Read more
source§fn and_then<F, Fut, R, R2>(self, f: F) -> AndThen<Self::Endpoint, F>where
F: Fn(R) -> Fut + Send + Sync,
Fut: Future<Output = Result<R2, Error>> + Send,
R: IntoResponse,
R2: IntoResponse,
Self: Sized,
Self::Endpoint: Endpoint<Output = R> + Sized,
fn and_then<F, Fut, R, R2>(self, f: F) -> AndThen<Self::Endpoint, F>where
F: Fn(R) -> Fut + Send + Sync,
Fut: Future<Output = Result<R2, Error>> + Send,
R: IntoResponse,
R2: IntoResponse,
Self: Sized,
Self::Endpoint: Endpoint<Output = R> + Sized,
source§fn catch_all_error<F, Fut, R>(self, f: F) -> CatchAllError<Self, F, R>where
F: Fn(Error) -> Fut + Send + Sync,
Fut: Future<Output = R> + Send,
R: IntoResponse + Send,
Self: Sized + Sync,
fn catch_all_error<F, Fut, R>(self, f: F) -> CatchAllError<Self, F, R>where
F: Fn(Error) -> Fut + Send + Sync,
Fut: Future<Output = R> + Send,
R: IntoResponse + Send,
Self: Sized + Sync,
Catch all errors and convert it into a response. Read more
source§fn catch_error<F, Fut, R, ErrType>(self, f: F) -> CatchError<Self, F, R, ErrType>where
F: Fn(ErrType) -> Fut + Send + Sync,
Fut: Future<Output = R> + Send,
R: IntoResponse + Send + Sync,
ErrType: 'static + Error + Send + Sync,
Self: Sized,
fn catch_error<F, Fut, R, ErrType>(self, f: F) -> CatchError<Self, F, R, ErrType>where
F: Fn(ErrType) -> Fut + Send + Sync,
Fut: Future<Output = R> + Send,
R: IntoResponse + Send + Sync,
ErrType: 'static + Error + Send + Sync,
Self: Sized,
Catch the specified type of error and convert it into a response. Read more
source§fn inspect_all_err<F>(self, f: F) -> InspectAllError<Self, F>where
F: Fn(&Error) + Send + Sync,
Self: Sized,
fn inspect_all_err<F>(self, f: F) -> InspectAllError<Self, F>where
F: Fn(&Error) + Send + Sync,
Self: Sized,
Does something with each error. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEndpoint for Twhere
T: Endpoint,
impl<T> IntoEndpoint for Twhere
T: Endpoint,
source§fn into_endpoint(self) -> <T as IntoEndpoint>::Endpoint
fn into_endpoint(self) -> <T as IntoEndpoint>::Endpoint
Converts this object into endpoint.