@@ -122,72 +122,10 @@ use std::{error::Error, fmt, io::Read};
122122use serde_json:: error:: Error as SerdeError ;
123123
124124use juniper:: {
125- http, serde:: Deserialize , DefaultScalarValue , GraphQLType , InputValue , RootNode , ScalarValue ,
125+ http, http:: GraphQLBatchRequest , DefaultScalarValue , GraphQLType , InputValue , RootNode ,
126+ ScalarValue ,
126127} ;
127128
128- #[ derive( serde_derive:: Deserialize ) ]
129- #[ serde( untagged) ]
130- #[ serde( bound = "InputValue<S>: Deserialize<'de>" ) ]
131- enum GraphQLBatchRequest < S = DefaultScalarValue >
132- where
133- S : ScalarValue ,
134- {
135- Single ( http:: GraphQLRequest < S > ) ,
136- Batch ( Vec < http:: GraphQLRequest < S > > ) ,
137- }
138-
139- #[ derive( serde_derive:: Serialize ) ]
140- #[ serde( untagged) ]
141- enum GraphQLBatchResponse < ' a , S = DefaultScalarValue >
142- where
143- S : ScalarValue ,
144- {
145- Single ( http:: GraphQLResponse < ' a , S > ) ,
146- Batch ( Vec < http:: GraphQLResponse < ' a , S > > ) ,
147- }
148-
149- impl < S > GraphQLBatchRequest < S >
150- where
151- S : ScalarValue ,
152- {
153- pub fn execute_sync < ' a , CtxT , QueryT , MutationT , Subscription > (
154- & ' a self ,
155- root_node : & ' a RootNode < QueryT , MutationT , Subscription , S > ,
156- context : & CtxT ,
157- ) -> GraphQLBatchResponse < ' a , S >
158- where
159- QueryT : GraphQLType < S , Context = CtxT > ,
160- MutationT : GraphQLType < S , Context = CtxT > ,
161- Subscription : GraphQLType < S , Context = CtxT > ,
162- {
163- match * self {
164- GraphQLBatchRequest :: Single ( ref request) => {
165- GraphQLBatchResponse :: Single ( request. execute_sync ( root_node, context) )
166- }
167- GraphQLBatchRequest :: Batch ( ref requests) => GraphQLBatchResponse :: Batch (
168- requests
169- . iter ( )
170- . map ( |request| request. execute_sync ( root_node, context) )
171- . collect ( ) ,
172- ) ,
173- }
174- }
175- }
176-
177- impl < ' a , S > GraphQLBatchResponse < ' a , S >
178- where
179- S : ScalarValue ,
180- {
181- fn is_ok ( & self ) -> bool {
182- match * self {
183- GraphQLBatchResponse :: Single ( ref response) => response. is_ok ( ) ,
184- GraphQLBatchResponse :: Batch ( ref responses) => {
185- responses. iter ( ) . all ( |response| response. is_ok ( ) )
186- }
187- }
188- }
189- }
190-
191129/// Handler that executes `GraphQL` queries in the given schema
192130///
193131/// The handler responds to GET requests and POST requests only. In GET
0 commit comments