Struct juniper::iron_handlers::GraphQLHandler
[−]
[src]
pub struct GraphQLHandler<'a, CtxFactory, Query, Mutation, CtxT> where
CtxFactory: Fn(&mut Request) -> CtxT + Send + Sync + 'static,
CtxT: 'static,
Query: GraphQLType<Context = CtxT> + Send + Sync + 'static,
Mutation: GraphQLType<Context = CtxT> + Send + Sync + 'static, { /* fields omitted */ }
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.
Methods
impl<'a, CtxFactory, Query, Mutation, CtxT> GraphQLHandler<'a, CtxFactory, Query, Mutation, CtxT> where
CtxFactory: Fn(&mut Request) -> CtxT + Send + Sync + 'static,
CtxT: 'static,
Query: GraphQLType<Context = CtxT> + Send + Sync + 'static,
Mutation: GraphQLType<Context = CtxT> + Send + Sync + 'static,
[src]
CtxFactory: Fn(&mut Request) -> CtxT + Send + Sync + 'static,
CtxT: 'static,
Query: GraphQLType<Context = CtxT> + Send + Sync + 'static,
Mutation: GraphQLType<Context = CtxT> + Send + Sync + 'static,
fn new(context_factory: CtxFactory, query: Query, mutation: Mutation) -> 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
impl<'a, CtxFactory, Query, Mutation, CtxT> Handler for GraphQLHandler<'a, CtxFactory, Query, Mutation, CtxT> where
CtxFactory: Fn(&mut Request) -> CtxT + Send + Sync + 'static,
CtxT: 'static,
Query: GraphQLType<Context = CtxT> + Send + Sync + 'static,
Mutation: GraphQLType<Context = CtxT> + Send + Sync + 'static,
'a: 'static,
[src]
CtxFactory: Fn(&mut Request) -> CtxT + Send + Sync + 'static,
CtxT: 'static,
Query: GraphQLType<Context = CtxT> + Send + Sync + 'static,
Mutation: GraphQLType<Context = CtxT> + Send + Sync + 'static,
'a: 'static,
fn handle(&self, req: &mut Request) -> IronResult<Response>
Produce a Response
from a Request, with the possibility of error.