Struct async_graphql_poem::GraphQLSubscription
source · [−]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
sourceimpl<Query, Mutation, Subscription> GraphQLSubscription<Query, Mutation, Subscription>
impl<Query, Mutation, Subscription> GraphQLSubscription<Query, Mutation, Subscription>
Trait Implementations
sourceimpl<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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> EndpointExt for T where
T: IntoEndpoint,
impl<T> EndpointExt for T where
T: IntoEndpoint,
sourcefn boxed<'a>(
self
) -> Box<dyn Endpoint<Output = <Self::Endpoint as Endpoint>::Output> + 'a, Global> where
Self: 'a,
fn boxed<'a>(
self
) -> Box<dyn Endpoint<Output = <Self::Endpoint as Endpoint>::Output> + 'a, Global> where
Self: 'a,
Wrap the endpoint in a Box.
sourcefn 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
sourcefn with_if<T>(
self,
enable: bool,
middleware: T
) -> EitherEndpoint<Self, <T as Middleware<Self::Endpoint>>::Output> where
T: Middleware<Self::Endpoint>,
fn with_if<T>(
self,
enable: bool,
middleware: T
) -> EitherEndpoint<Self, <T as Middleware<Self::Endpoint>>::Output> where
T: Middleware<Self::Endpoint>,
if enable
is true
then use middleware to transform this endpoint. Read more
sourcefn data<T>(self, data: T) -> AddDataEndpoint<Self::Endpoint, T> where
T: 'static + Clone + Send + Sync,
fn data<T>(self, data: T) -> AddDataEndpoint<Self::Endpoint, T> where
T: 'static + Clone + Send + Sync,
Attach a state data to the endpoint, similar to with(AddData(T))
. Read more
sourcefn data_opt<T>(
self,
data: Option<T>
) -> EitherEndpoint<AddDataEndpoint<Self::Endpoint, T>, Self> where
T: 'static + Clone + Send + Sync,
fn data_opt<T>(
self,
data: Option<T>
) -> EitherEndpoint<AddDataEndpoint<Self::Endpoint, T>, Self> where
T: 'static + Clone + Send + Sync,
if data
is Some(T)
then attach the value to the endpoint.
sourcefn before<F, Fut>(self, f: F) -> Before<Self, F> where
F: Fn(Request) -> Fut + Send + Sync,
Fut: Future<Output = Result<Request, Error>> + Send,
fn before<F, Fut>(self, f: F) -> Before<Self, F> where
F: Fn(Request) -> Fut + Send + Sync,
Fut: Future<Output = Result<Request, Error>> + Send,
Maps the request of this endpoint. Read more
sourcefn 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,
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,
Maps the output of this endpoint. Read more
sourcefn 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,
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,
Maps the request and response of this endpoint. Read more
sourcefn map_to_response(self) -> MapToResponse<Self::Endpoint>
fn map_to_response(self) -> MapToResponse<Self::Endpoint>
sourcefn to_response(self) -> ToResponse<Self::Endpoint>
fn to_response(self) -> ToResponse<Self::Endpoint>
sourcefn 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::Endpoint: Endpoint,
Self::Endpoint: Sized,
<Self::Endpoint as Endpoint>::Output == R,
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::Endpoint: Endpoint,
Self::Endpoint: Sized,
<Self::Endpoint as Endpoint>::Output == R,
Maps the response of this endpoint. Read more
sourcefn 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::Endpoint: Endpoint,
Self::Endpoint: Sized,
<Self::Endpoint as Endpoint>::Output == R,
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::Endpoint: Endpoint,
Self::Endpoint: Sized,
<Self::Endpoint as Endpoint>::Output == R,
Calls f
if the result is Ok
, otherwise returns the Err
value of
self. Read more
sourcefn 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: 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: Sync,
Catch all errors and convert it into a response. Read more
sourcefn 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,
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,
Catch the specified type of error and convert it into a response. Read more
sourcefn inspect_all_err<F>(self, f: F) -> InspectAllError<Self, F> where
F: Fn(&Error) + Send + Sync,
fn inspect_all_err<F>(self, f: F) -> InspectAllError<Self, F> where
F: Fn(&Error) + Send + Sync,
Does something with each error. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoEndpoint for T where
T: Endpoint,
impl<T> IntoEndpoint for T where
T: Endpoint,
type Endpoint = T
type Endpoint = T
Represents the endpoint type.
sourcefn into_endpoint(self) -> <T as IntoEndpoint>::Endpoint
fn into_endpoint(self) -> <T as IntoEndpoint>::Endpoint
Converts this object into endpoint.
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more