GraphQLHandler

Struct GraphQLHandler 

Source
pub struct GraphQLHandler<'a, CtxFactory, Query, Mutation, Subscription, CtxT, S = DefaultScalarValue>
where S: ScalarValue, CtxFactory: Fn(&mut Request<'_, '_>) -> IronResult<CtxT> + Send + Sync + 'static, CtxT: 'static, Query: GraphQLType<S, Context = CtxT> + Send + Sync + 'static, Mutation: GraphQLType<S, Context = CtxT> + Send + Sync + 'static, Subscription: GraphQLType<S, Context = CtxT> + Send + Sync + 'static,
{ /* private fields */ }
Expand description

Handler that executes GraphQL queries in the given schema

The handler responds to GET requests and POST requests only. In GET requests, the query should be supplied in the query URL parameter, e.g. http://localhost:3000/graphql?query={hero{name}}.

POST requests support both queries and variables. POST a JSON document to this endpoint containing the field "query" and optionally "variables". The variables should be a JSON object containing the variable to value mapping.

Implementations§

Source§

impl<'a, CtxFactory, Query, Mutation, Subscription, CtxT, S> GraphQLHandler<'a, CtxFactory, Query, Mutation, Subscription, CtxT, S>
where S: ScalarValue + Send + Sync + 'static, CtxFactory: Fn(&mut Request<'_, '_>) -> IronResult<CtxT> + Send + Sync + 'static, CtxT: Send + Sync + 'static, Query: GraphQLType<S, Context = CtxT, TypeInfo = ()> + Send + Sync + 'static, Mutation: GraphQLType<S, Context = CtxT, TypeInfo = ()> + Send + Sync + 'static, Subscription: GraphQLType<S, Context = CtxT, TypeInfo = ()> + Send + Sync + 'static,

Source

pub fn new( context_factory: CtxFactory, query: Query, mutation: Mutation, subscription: Subscription, ) -> Self

Build a new GraphQL handler

The context factory will receive the Iron request object and is expected to construct a context object for the given schema. This can be used to construct e.g. database connections or similar data that the schema needs to execute the query.

Trait Implementations§

Source§

impl<'a, CtxFactory, Query, Mutation, Subscription, CtxT, S> Handler for GraphQLHandler<'a, CtxFactory, Query, Mutation, Subscription, CtxT, S>
where S: ScalarValue + Sync + Send + 'static, CtxFactory: Fn(&mut Request<'_, '_>) -> IronResult<CtxT> + Send + Sync + 'static, CtxT: Send + Sync + 'static, Query: GraphQLType<S, Context = CtxT, TypeInfo = ()> + Send + Sync + 'static, Mutation: GraphQLType<S, Context = CtxT, TypeInfo = ()> + Send + Sync + 'static, Subscription: GraphQLType<S, Context = CtxT, TypeInfo = ()> + Send + Sync + 'static, 'a: 'static,

Source§

fn handle(&self, req: &mut Request<'_, '_>) -> IronResult<Response>

Produce a Response from a Request, with the possibility of error.

Auto Trait Implementations§

§

impl<'a, CtxFactory, Query, Mutation, Subscription, CtxT, S> Freeze for GraphQLHandler<'a, CtxFactory, Query, Mutation, Subscription, CtxT, S>
where CtxFactory: Freeze, Query: Freeze, <Query as GraphQLValue<S>>::TypeInfo: Freeze, Mutation: Freeze, <Mutation as GraphQLValue<S>>::TypeInfo: Freeze, Subscription: Freeze, <Subscription as GraphQLValue<S>>::TypeInfo: Freeze,

§

impl<'a, CtxFactory, Query, Mutation, Subscription, CtxT, S> RefUnwindSafe for GraphQLHandler<'a, CtxFactory, Query, Mutation, Subscription, CtxT, S>
where CtxFactory: RefUnwindSafe, Query: RefUnwindSafe, <Query as GraphQLValue<S>>::TypeInfo: RefUnwindSafe, Mutation: RefUnwindSafe, <Mutation as GraphQLValue<S>>::TypeInfo: RefUnwindSafe, Subscription: RefUnwindSafe, <Subscription as GraphQLValue<S>>::TypeInfo: RefUnwindSafe, S: RefUnwindSafe,

§

impl<'a, CtxFactory, Query, Mutation, Subscription, CtxT, S> Send for GraphQLHandler<'a, CtxFactory, Query, Mutation, Subscription, CtxT, S>
where <Query as GraphQLValue<S>>::TypeInfo: Send, <Mutation as GraphQLValue<S>>::TypeInfo: Send, <Subscription as GraphQLValue<S>>::TypeInfo: Send, S: Send,

§

impl<'a, CtxFactory, Query, Mutation, Subscription, CtxT, S> Sync for GraphQLHandler<'a, CtxFactory, Query, Mutation, Subscription, CtxT, S>
where <Query as GraphQLValue<S>>::TypeInfo: Sync, <Mutation as GraphQLValue<S>>::TypeInfo: Sync, <Subscription as GraphQLValue<S>>::TypeInfo: Sync, S: Sync,

§

impl<'a, CtxFactory, Query, Mutation, Subscription, CtxT, S> Unpin for GraphQLHandler<'a, CtxFactory, Query, Mutation, Subscription, CtxT, S>
where CtxFactory: Unpin, Query: Unpin, <Query as GraphQLValue<S>>::TypeInfo: Unpin, Mutation: Unpin, <Mutation as GraphQLValue<S>>::TypeInfo: Unpin, Subscription: Unpin, <Subscription as GraphQLValue<S>>::TypeInfo: Unpin, S: Unpin,

§

impl<'a, CtxFactory, Query, Mutation, Subscription, CtxT, S> UnwindSafe for GraphQLHandler<'a, CtxFactory, Query, Mutation, Subscription, CtxT, S>
where CtxFactory: UnwindSafe, Query: UnwindSafe, <Query as GraphQLValue<S>>::TypeInfo: UnwindSafe, Mutation: UnwindSafe, <Mutation as GraphQLValue<S>>::TypeInfo: UnwindSafe, Subscription: UnwindSafe, <Subscription as GraphQLValue<S>>::TypeInfo: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PersistentInto<Arc<Mutex<T>>> for T

Source§

fn persistent_into(self) -> Arc<Mutex<T>>

Convert self into a value of type T.
Source§

impl<T> PersistentInto<Arc<RwLock<T>>> for T

Source§

fn persistent_into(self) -> Arc<RwLock<T>>

Convert self into a value of type T.
Source§

impl<T> PersistentInto<Arc<T>> for T

Source§

fn persistent_into(self) -> Arc<T>

Convert self into a value of type T.
Source§

impl<T> PersistentInto<T> for T

Source§

fn persistent_into(self) -> T

Convert self into a value of type T.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Typeable for T
where T: Any,

Source§

fn get_type(&self) -> TypeId

Get the TypeId of this object.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> UnsafeAny for T
where T: Any,