Relax Iron handler context trait requirements

This commit is contained in:
Magnus Hallin 2016-11-30 20:50:08 +01:00
parent f7123ed9db
commit e5167e1aae

View file

@ -24,7 +24,7 @@ use ::{InputValue, GraphQLType, RootNode, execute};
/// mapping. /// mapping.
pub struct GraphQLHandler<CtxFactory, Query, Mutation, CtxT> pub struct GraphQLHandler<CtxFactory, Query, Mutation, CtxT>
where CtxFactory: Fn(&mut Request) -> CtxT + Send + Sync + 'static, where CtxFactory: Fn(&mut Request) -> CtxT + Send + Sync + 'static,
CtxT: Send + Sync + 'static, CtxT: 'static,
Query: GraphQLType<CtxT> + Send + Sync + 'static, Query: GraphQLType<CtxT> + Send + Sync + 'static,
Mutation: GraphQLType<CtxT> + Send + Sync + 'static, Mutation: GraphQLType<CtxT> + Send + Sync + 'static,
{ {
@ -40,14 +40,14 @@ pub struct GraphiQLHandler {
impl<CtxFactory, Query, Mutation, CtxT> impl<CtxFactory, Query, Mutation, CtxT>
GraphQLHandler<CtxFactory, Query, Mutation, CtxT> GraphQLHandler<CtxFactory, Query, Mutation, CtxT>
where CtxFactory: Fn(&mut Request) -> CtxT + Send + Sync + 'static, where CtxFactory: Fn(&mut Request) -> CtxT + Send + Sync + 'static,
CtxT: Send + Sync + 'static, CtxT: 'static,
Query: GraphQLType<CtxT> + Send + Sync + 'static, Query: GraphQLType<CtxT> + Send + Sync + 'static,
Mutation: GraphQLType<CtxT> + Send + Sync + 'static, Mutation: GraphQLType<CtxT> + Send + Sync + 'static,
{ {
/// Build a new GraphQL handler /// Build a new GraphQL handler
/// ///
/// The context factory will receive the Iron request object and is /// The context factory will receive the Iron request object and is
/// expected to construct a context object for the given schema. This can /// expected to construct a context object for the given schema. This can
/// be used to construct e.g. database connections or similar data that /// be used to construct e.g. database connections or similar data that
/// the schema needs to execute the query. /// the schema needs to execute the query.
pub fn new(context_factory: CtxFactory, query: Query, mutation: Mutation) -> Self { pub fn new(context_factory: CtxFactory, query: Query, mutation: Mutation) -> Self {
@ -149,7 +149,7 @@ impl<CtxFactory, Query, Mutation, CtxT>
Handler Handler
for GraphQLHandler<CtxFactory, Query, Mutation, CtxT> for GraphQLHandler<CtxFactory, Query, Mutation, CtxT>
where CtxFactory: Fn(&mut Request) -> CtxT + Send + Sync + 'static, where CtxFactory: Fn(&mut Request) -> CtxT + Send + Sync + 'static,
CtxT: Send + Sync + 'static, CtxT: 'static,
Query: GraphQLType<CtxT> + Send + Sync + 'static, Query: GraphQLType<CtxT> + Send + Sync + 'static,
Mutation: GraphQLType<CtxT> + Send + Sync + 'static, Mutation: GraphQLType<CtxT> + Send + Sync + 'static,
{ {
@ -240,7 +240,7 @@ impl Handler for GraphiQLHandler {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use rustc_serialize::json::Json; use rustc_serialize::json::Json;
use iron::prelude::*; use iron::prelude::*;
use iron::status; use iron::status;
use iron::headers; use iron::headers;