From 60953830195f974c7e3ba129d199d5cdbc955056 Mon Sep 17 00:00:00 2001 From: Koxiaet <38139193+Koxiaet@users.noreply.github.com> Date: Sat, 19 Sep 2020 18:10:46 +0100 Subject: [PATCH] Warp: Replace `BoxedFilter` with `impl Filter` --- integrations/warp/src/lib.rs | 29 ++++++++++++++++------------- src/lib.rs | 4 ++-- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/integrations/warp/src/lib.rs b/integrations/warp/src/lib.rs index e00cd940..1221290a 100644 --- a/integrations/warp/src/lib.rs +++ b/integrations/warp/src/lib.rs @@ -14,7 +14,6 @@ use hyper::Method; use std::io::{self, ErrorKind}; use std::sync::Arc; use warp::filters::ws; -use warp::filters::BoxedFilter; use warp::reject::Reject; use warp::reply::Response; use warp::{Buf, Filter, Rejection, Reply}; @@ -71,10 +70,13 @@ impl Reject for BadRequest {} /// ``` pub fn graphql( schema: Schema, -) -> BoxedFilter<(( - Schema, - async_graphql::Request, -),)> +) -> impl Filter< + Extract = (( + Schema, + async_graphql::Request, + ),), + Error = Rejection, +> + Clone where Query: ObjectType + Send + Sync + 'static, Mutation: ObjectType + Send + Sync + 'static, @@ -87,10 +89,13 @@ where pub fn graphql_opts( schema: Schema, opts: MultipartOptions, -) -> BoxedFilter<(( - Schema, - async_graphql::Request, -),)> +) -> impl Filter< + Extract = (( + Schema, + async_graphql::Request, + ),), + Error = Rejection, +> + Clone where Query: ObjectType + Send + Sync + 'static, Mutation: ObjectType + Send + Sync + 'static, @@ -129,7 +134,6 @@ where } }, ) - .boxed() } /// GraphQL subscription filter @@ -168,7 +172,7 @@ where /// ``` pub fn graphql_subscription( schema: Schema, -) -> BoxedFilter<(impl Reply,)> +) -> impl Filter + Clone where Query: ObjectType + Sync + Send + 'static, Mutation: ObjectType + Sync + Send + 'static, @@ -185,7 +189,7 @@ where pub fn graphql_subscription_with_data( schema: Schema, initializer: Option, -) -> BoxedFilter<(impl Reply,)> +) -> impl Filter + Clone where Query: ObjectType + Sync + Send + 'static, Mutation: ObjectType + Sync + Send + 'static, @@ -219,7 +223,6 @@ where }, ) .map(|reply| warp::reply::with_header(reply, "Sec-WebSocket-Protocol", "graphql-ws")) - .boxed() } /// GraphQL reply diff --git a/src/lib.rs b/src/lib.rs index 745784e1..245a0cae 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -140,14 +140,14 @@ pub use async_stream; #[doc(hidden)] pub use async_trait; #[doc(hidden)] +pub use context::ContextSelectionSet; +#[doc(hidden)] pub use futures; #[doc(hidden)] pub use indexmap; #[doc(hidden)] pub use serde_json; #[doc(hidden)] -pub use context::ContextSelectionSet; -#[doc(hidden)] pub use subscription::SubscriptionType; pub use async_graphql_parser as parser;