@@ -231,7 +231,9 @@ pub mod subscriptions {
231
231
} ;
232
232
use futures:: { Stream , StreamExt } ;
233
233
use juniper:: { http:: GraphQLRequest , InputValue , ScalarValue , SubscriptionCoordinator } ;
234
- use juniper_subscriptions:: { message_types:: * , MessageTypes , Coordinator , SubscriptionStateHandler , SubscriptionState } ;
234
+ use juniper_subscriptions:: {
235
+ message_types:: * , Coordinator , MessageTypes , SubscriptionState , SubscriptionStateHandler ,
236
+ } ;
235
237
use serde:: { Deserialize , Serialize } ;
236
238
use std:: {
237
239
collections:: HashMap ,
@@ -260,7 +262,7 @@ pub mod subscriptions {
260
262
juniper:: GraphQLSubscriptionType < S , Context = Context > + Send + Sync + ' static ,
261
263
Subscription :: TypeInfo : Send + Sync ,
262
264
SubHandler : SubscriptionStateHandler < Context , E > + ' static + std:: marker:: Unpin ,
263
- E : ' static + std:: error:: Error + std:: marker:: Unpin
265
+ E : ' static + std:: error:: Error + std:: marker:: Unpin ,
264
266
{
265
267
let mut res = handshake_with_protocols ( req, & [ "graphql-ws" ] ) ?;
266
268
Ok ( res. streaming ( WebsocketContext :: create ( actor, stream) ) )
@@ -274,7 +276,7 @@ pub mod subscriptions {
274
276
Context ,
275
277
S ,
276
278
SubHandler ,
277
- E
279
+ E ,
278
280
> (
279
281
coordinator : web:: Data < Coordinator < ' static , Query , Mutation , Subscription , Context , S > > ,
280
282
context : Context ,
@@ -293,7 +295,7 @@ pub mod subscriptions {
293
295
juniper:: GraphQLSubscriptionType < S , Context = Context > + Send + Sync + ' static ,
294
296
Subscription :: TypeInfo : Send + Sync ,
295
297
SubHandler : SubscriptionStateHandler < Context , E > + ' static + std:: marker:: Unpin ,
296
- E : ' static + std:: error:: Error + std:: marker:: Unpin
298
+ E : ' static + std:: error:: Error + std:: marker:: Unpin ,
297
299
{
298
300
start (
299
301
GraphQLWSSession {
@@ -302,7 +304,7 @@ pub mod subscriptions {
302
304
map_req_id_to_spawn_handle : HashMap :: new ( ) ,
303
305
has_started : Arc :: new ( AtomicBool :: new ( false ) ) ,
304
306
handler,
305
- error_handler : std:: marker:: PhantomData
307
+ error_handler : std:: marker:: PhantomData ,
306
308
} ,
307
309
& req,
308
310
stream,
@@ -321,14 +323,14 @@ pub mod subscriptions {
321
323
juniper:: GraphQLSubscriptionType < S , Context = Context > + Send + Sync + ' static ,
322
324
Subscription :: TypeInfo : Send + Sync ,
323
325
SubHandler : SubscriptionStateHandler < Context , E > + ' static + std:: marker:: Unpin ,
324
- E : ' static + std:: error:: Error + std:: marker:: Unpin
326
+ E : ' static + std:: error:: Error + std:: marker:: Unpin ,
325
327
{
326
328
pub map_req_id_to_spawn_handle : HashMap < String , SpawnHandle > ,
327
329
pub has_started : Arc < AtomicBool > ,
328
330
pub graphql_context : Context ,
329
331
pub coordinator : Arc < Coordinator < ' static , Query , Mutation , Subscription , Context , S > > ,
330
332
pub handler : Option < SubHandler > ,
331
- error_handler : std:: marker:: PhantomData < E >
333
+ error_handler : std:: marker:: PhantomData < E > ,
332
334
}
333
335
334
336
impl < Query , Mutation , Subscription , Context , S , SubHandler , E > Actor
@@ -344,7 +346,7 @@ pub mod subscriptions {
344
346
juniper:: GraphQLSubscriptionType < S , Context = Context > + Send + Sync + ' static ,
345
347
Subscription :: TypeInfo : Send + Sync ,
346
348
SubHandler : SubscriptionStateHandler < Context , E > + ' static + std:: marker:: Unpin ,
347
- E : ' static + std:: error:: Error + std:: marker:: Unpin
349
+ E : ' static + std:: error:: Error + std:: marker:: Unpin ,
348
350
{
349
351
type Context = ws:: WebsocketContext <
350
352
GraphQLWSSession < Query , Mutation , Subscription , Context , S , SubHandler , E > ,
@@ -365,7 +367,7 @@ pub mod subscriptions {
365
367
juniper:: GraphQLSubscriptionType < S , Context = Context > + Send + Sync + ' static ,
366
368
Subscription :: TypeInfo : Send + Sync ,
367
369
SubHandler : SubscriptionStateHandler < Context , E > + ' static + std:: marker:: Unpin ,
368
- E : ' static + std:: error:: Error + std:: marker:: Unpin
370
+ E : ' static + std:: error:: Error + std:: marker:: Unpin ,
369
371
{
370
372
fn gql_connection_ack ( ) -> String {
371
373
format ! ( r#"{{"type":"{}", "payload": null }}"# , GQL_CONNECTION_ACK )
@@ -476,7 +478,7 @@ pub mod subscriptions {
476
478
juniper:: GraphQLSubscriptionType < S , Context = Context > + Send + Sync + ' static ,
477
479
Subscription :: TypeInfo : Send + Sync ,
478
480
SubHandler : SubscriptionStateHandler < Context , E > + ' static + std:: marker:: Unpin ,
479
- E : ' static + std:: error:: Error + std:: marker:: Unpin
481
+ E : ' static + std:: error:: Error + std:: marker:: Unpin ,
480
482
{
481
483
fn handle ( & mut self , msg : Result < ws:: Message , ws:: ProtocolError > , ctx : & mut Self :: Context ) {
482
484
let msg = match msg {
@@ -493,14 +495,16 @@ pub mod subscriptions {
493
495
let m = text. trim ( ) ;
494
496
let request: WsPayload < S > = match serde_json:: from_str ( m) {
495
497
Ok ( payload) => payload,
496
- Err ( _) => { return ; }
498
+ Err ( _) => {
499
+ return ;
500
+ }
497
501
} ;
498
502
match request. type_ {
499
503
MessageTypes :: GqlConnectionInit => {
500
504
if let Some ( handler) = & self . handler {
501
505
let state = SubscriptionState :: OnConnection (
502
506
Some ( String :: from ( m) ) ,
503
- & mut self . graphql_context
507
+ & mut self . graphql_context ,
504
508
) ;
505
509
let on_connect_result = handler. handle ( state) ;
506
510
if let Err ( _err) = on_connect_result {
@@ -520,7 +524,7 @@ pub mod subscriptions {
520
524
ctx. text ( Self :: gql_connection_ka ( ) ) ;
521
525
}
522
526
} ) ;
523
- } ,
527
+ }
524
528
MessageTypes :: GqlStart if has_started_value => {
525
529
let coordinator = self . coordinator . clone ( ) ;
526
530
let mut context = self . graphql_context . clone ( ) ;
@@ -556,9 +560,8 @@ pub mod subscriptions {
556
560
MessageTypes :: GqlStop if has_started_value => {
557
561
let request_id = request. id . unwrap_or ( "1" . to_owned ( ) ) ;
558
562
if let Some ( handler) = & self . handler {
559
- let state = SubscriptionState :: OnOperationComplete (
560
- & self . graphql_context
561
- ) ;
563
+ let state =
564
+ SubscriptionState :: OnOperationComplete ( & self . graphql_context ) ;
562
565
handler. handle ( state) . unwrap ( ) ;
563
566
}
564
567
match self . map_req_id_to_spawn_handle . remove ( & request_id) {
@@ -577,14 +580,14 @@ pub mod subscriptions {
577
580
// ))
578
581
}
579
582
}
580
- } ,
583
+ }
581
584
MessageTypes :: GqlConnectionTerminate => {
582
585
if let Some ( handler) = & self . handler {
583
586
let state = SubscriptionState :: OnDisconnect ( & self . graphql_context ) ;
584
587
handler. handle ( state) . unwrap ( ) ;
585
588
}
586
589
ctx. stop ( ) ;
587
- } ,
590
+ }
588
591
_ => { }
589
592
}
590
593
}
0 commit comments