diff --git a/juniper/src/http/mod.rs b/juniper/src/http/mod.rs index 15fc695b..5848fe94 100644 --- a/juniper/src/http/mod.rs +++ b/juniper/src/http/mod.rs @@ -247,8 +247,6 @@ where QueryT: crate::GraphQLType<S, Context = CtxT>, MutationT: crate::GraphQLType<S, Context = CtxT>, SubscriptionT: crate::GraphQLType<S, Context = CtxT>, - 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 7b2b82ba..e50350f7 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<S>: Deserialize<'de>")] -enum GraphQLBatchRequest<S = DefaultScalarValue> -where - S: ScalarValue, -{ - Single(http::GraphQLRequest<S>), - Batch(Vec<http::GraphQLRequest<S>>), -} - -#[derive(serde_derive::Serialize)] -#[serde(untagged)] -enum GraphQLBatchResponse<'a, S = DefaultScalarValue> -where - S: ScalarValue, -{ - Single(http::GraphQLResponse<'a, S>), - Batch(Vec<http::GraphQLResponse<'a, S>>), -} - -impl<S> GraphQLBatchRequest<S> -where - S: ScalarValue, -{ - pub fn execute_sync<'a, CtxT, QueryT, MutationT, SubscriptionT>( - &'a self, - root_node: &'a RootNode<QueryT, MutationT, SubscriptionT, S>, - context: &CtxT, - ) -> GraphQLBatchResponse<'a, S> - where - QueryT: GraphQLType<S, Context = CtxT>, - MutationT: GraphQLType<S, Context = CtxT>, - SubscriptionT: GraphQLType<S, Context = CtxT>, - { - 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<Option<&str>> { - 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 28341f15..edd4e279 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<S = DefaultScalarValue>(GraphQLBatchRequest<S>) 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<String> { impl<S> GraphQLRequest<S> where - S: ScalarValue + Sync + Send, + S: ScalarValue, { - /// Execute an incoming GraphQL query synchronously. + /// Synchronously execute an incoming GraphQL query. pub fn execute_sync<CtxT, QueryT, MutationT, SubscriptionT>( &self, root_node: &RootNode<QueryT, MutationT, SubscriptionT, S>, @@ -97,8 +97,6 @@ where QueryT: GraphQLType<S, Context = CtxT>, MutationT: GraphQLType<S, Context = CtxT>, SubscriptionT: GraphQLType<S, Context = CtxT>, - 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<CtxT, QueryT, MutationT, SubscriptionT>( &self, root_node: &RootNode<'_, QueryT, MutationT, SubscriptionT, S>,