@@ -17,7 +17,7 @@ pub async fn graphql_sync<CtxT, QueryT, MutationT, SubscriptionT, S>(
17
17
root_node : Arc < RootNode < ' static , QueryT , MutationT , SubscriptionT , S > > ,
18
18
context : Arc < CtxT > ,
19
19
req : Request < Body > ,
20
- ) -> Result < Response < Body > , hyper :: Error >
20
+ ) -> Response < Body >
21
21
where
22
22
QueryT : GraphQLType < S , Context = CtxT > ,
23
23
QueryT :: TypeInfo : Sync ,
@@ -28,17 +28,17 @@ where
28
28
CtxT : Sync ,
29
29
S : ScalarValue + Send + Sync ,
30
30
{
31
- Ok ( match parse_req ( req) . await {
31
+ match parse_req ( req) . await {
32
32
Ok ( req) => execute_request_sync ( root_node, context, req) . await ,
33
33
Err ( resp) => resp,
34
- } )
34
+ }
35
35
}
36
36
37
37
pub async fn graphql < CtxT , QueryT , MutationT , SubscriptionT , S > (
38
38
root_node : Arc < RootNode < ' static , QueryT , MutationT , SubscriptionT , S > > ,
39
39
context : Arc < CtxT > ,
40
40
req : Request < Body > ,
41
- ) -> Result < Response < Body > , hyper :: Error >
41
+ ) -> Response < Body >
42
42
where
43
43
QueryT : GraphQLTypeAsync < S , Context = CtxT > ,
44
44
QueryT :: TypeInfo : Sync ,
@@ -49,10 +49,10 @@ where
49
49
CtxT : Sync ,
50
50
S : ScalarValue + Send + Sync ,
51
51
{
52
- Ok ( match parse_req ( req) . await {
52
+ match parse_req ( req) . await {
53
53
Ok ( req) => execute_request ( root_node, context, req) . await ,
54
54
Err ( resp) => resp,
55
- } )
55
+ }
56
56
}
57
57
58
58
async fn parse_req < S : ScalarValue > (
@@ -121,26 +121,26 @@ async fn parse_post_graphql_req<S: ScalarValue>(
121
121
pub async fn graphiql (
122
122
graphql_endpoint : & str ,
123
123
subscriptions_endpoint : Option < & str > ,
124
- ) -> Result < Response < Body > , hyper :: Error > {
124
+ ) -> Response < Body > {
125
125
let mut resp = new_html_response ( StatusCode :: OK ) ;
126
126
// XXX: is the call to graphiql_source blocking?
127
127
* resp. body_mut ( ) = Body :: from ( juniper:: http:: graphiql:: graphiql_source (
128
128
graphql_endpoint,
129
129
subscriptions_endpoint,
130
130
) ) ;
131
- Ok ( resp)
131
+ resp
132
132
}
133
133
134
134
pub async fn playground (
135
135
graphql_endpoint : & str ,
136
136
subscriptions_endpoint : Option < & str > ,
137
- ) -> Result < Response < Body > , hyper :: Error > {
137
+ ) -> Response < Body > {
138
138
let mut resp = new_html_response ( StatusCode :: OK ) ;
139
139
* resp. body_mut ( ) = Body :: from ( juniper:: http:: playground:: playground_source (
140
140
graphql_endpoint,
141
141
subscriptions_endpoint,
142
142
) ) ;
143
- Ok ( resp)
143
+ resp
144
144
}
145
145
146
146
fn render_error ( err : GraphQLRequestError ) -> Response < Body > {
@@ -321,7 +321,7 @@ mod tests {
321
321
EmptyMutation , EmptySubscription , RootNode ,
322
322
} ;
323
323
use reqwest:: { self , blocking:: Response as ReqwestResponse } ;
324
- use std:: { net:: SocketAddr , sync:: Arc , thread, time:: Duration } ;
324
+ use std:: { convert :: Infallible , net:: SocketAddr , sync:: Arc , thread, time:: Duration } ;
325
325
326
326
struct TestHyperIntegration {
327
327
port : u16 ,
@@ -404,7 +404,7 @@ mod tests {
404
404
}
405
405
} ;
406
406
async move {
407
- if matches {
407
+ Ok :: < _ , Infallible > ( if matches {
408
408
if is_sync {
409
409
super :: graphql_sync ( root_node, ctx, req) . await
410
410
} else {
@@ -413,8 +413,8 @@ mod tests {
413
413
} else {
414
414
let mut resp = Response :: new ( Body :: empty ( ) ) ;
415
415
* resp. status_mut ( ) = StatusCode :: NOT_FOUND ;
416
- Ok ( resp)
417
- }
416
+ resp
417
+ } )
418
418
}
419
419
} ) )
420
420
}
0 commit comments