diff --git a/juniper/src/http/mod.rs b/juniper/src/http/mod.rs index 15fc695b5..5848fe94a 100644 --- a/juniper/src/http/mod.rs +++ b/juniper/src/http/mod.rs @@ -247,8 +247,6 @@ where QueryT: crate::GraphQLType, MutationT: crate::GraphQLType, SubscriptionT: crate::GraphQLType, - SubscriptionT::TypeInfo: Send + Sync, - CtxT: Send + Sync, { match *self { GraphQLBatchRequest::Single(ref request) => { diff --git a/juniper_rocket/src/lib.rs b/juniper_rocket/src/lib.rs index 7b2b82bab..e50350f75 100644 --- a/juniper_rocket/src/lib.rs +++ b/juniper_rocket/src/lib.rs @@ -54,81 +54,9 @@ use rocket::{ use juniper::{http, InputValue}; use juniper::{ - serde::Deserialize, DefaultScalarValue, FieldError, GraphQLType, RootNode, ScalarValue, + http::GraphQLBatchRequest, DefaultScalarValue, FieldError, GraphQLType, RootNode, ScalarValue, }; -#[derive(Debug, serde_derive::Deserialize, PartialEq)] -#[serde(untagged)] -#[serde(bound = "InputValue: Deserialize<'de>")] -enum GraphQLBatchRequest -where - S: ScalarValue, -{ - Single(http::GraphQLRequest), - Batch(Vec>), -} - -#[derive(serde_derive::Serialize)] -#[serde(untagged)] -enum GraphQLBatchResponse<'a, S = DefaultScalarValue> -where - S: ScalarValue, -{ - Single(http::GraphQLResponse<'a, S>), - Batch(Vec>), -} - -impl GraphQLBatchRequest -where - S: ScalarValue, -{ - pub fn execute_sync<'a, CtxT, QueryT, MutationT, SubscriptionT>( - &'a self, - root_node: &'a RootNode, - context: &CtxT, - ) -> GraphQLBatchResponse<'a, S> - where - QueryT: GraphQLType, - MutationT: GraphQLType, - SubscriptionT: GraphQLType, - { - match *self { - GraphQLBatchRequest::Single(ref request) => { - GraphQLBatchResponse::Single(request.execute_sync(root_node, context)) - } - GraphQLBatchRequest::Batch(ref requests) => GraphQLBatchResponse::Batch( - requests - .iter() - .map(|request| request.execute_sync(root_node, context)) - .collect(), - ), - } - } - - pub fn operation_names(&self) -> Vec> { - match self { - GraphQLBatchRequest::Single(req) => vec![req.operation_name()], - GraphQLBatchRequest::Batch(reqs) => { - reqs.iter().map(|req| req.operation_name()).collect() - } - } - } -} - -impl<'a, S> GraphQLBatchResponse<'a, S> -where - S: ScalarValue, -{ - fn is_ok(&self) -> bool { - match *self { - GraphQLBatchResponse::Single(ref response) => response.is_ok(), - GraphQLBatchResponse::Batch(ref responses) => { - responses.iter().all(|response| response.is_ok()) - } - } - } -} - /// Simple wrapper around an incoming GraphQL request /// /// See the `http` module for more information. This type can be constructed diff --git a/juniper_rocket_async/src/lib.rs b/juniper_rocket_async/src/lib.rs index 28341f154..edd4e279e 100644 --- a/juniper_rocket_async/src/lib.rs +++ b/juniper_rocket_async/src/lib.rs @@ -65,7 +65,7 @@ use juniper::{ #[derive(Debug, PartialEq)] pub struct GraphQLRequest(GraphQLBatchRequest) where - S: ScalarValue + Send + Sync; + S: ScalarValue; /// Simple wrapper around the result of executing a GraphQL query pub struct GraphQLResponse(pub Status, pub String); @@ -85,9 +85,9 @@ pub fn playground_source(graphql_endpoint_url: &str) -> content::Html { impl GraphQLRequest where - S: ScalarValue + Sync + Send, + S: ScalarValue, { - /// Execute an incoming GraphQL query synchronously. + /// Synchronously execute an incoming GraphQL query. pub fn execute_sync( &self, root_node: &RootNode, @@ -97,8 +97,6 @@ where QueryT: GraphQLType, MutationT: GraphQLType, SubscriptionT: GraphQLType, - SubscriptionT::TypeInfo: Send + Sync, - CtxT: Send + Sync, { let response = self.0.execute_sync(root_node, context); let status = if response.is_ok() { @@ -111,7 +109,7 @@ where GraphQLResponse(status, json) } - /// Asynchronously execute an incoming GraphQL query + /// Asynchronously execute an incoming GraphQL query. pub async fn execute( &self, root_node: &RootNode<'_, QueryT, MutationT, SubscriptionT, S>,