@@ -12,11 +12,11 @@ public actor Server<
1212 SubscriptionSequenceType. Element == GraphQLResult
1313{
1414 let messenger : Messenger
15-
15+
1616 let onInit : ( InitPayload ) async throws -> InitPayloadResult
1717 let onExecute : ( GraphQLRequest , InitPayloadResult ) async throws -> GraphQLResult
1818 let onSubscribe : ( GraphQLRequest , InitPayloadResult ) async throws -> SubscriptionSequenceType
19-
19+
2020 let onMessage : ( String ) async throws -> Void
2121 let onOperationComplete : ( String ) async throws -> Void
2222 let onOperationError : ( String , [ Error ] ) async throws -> Void
@@ -44,7 +44,7 @@ public actor Server<
4444 onSubscribe: @escaping ( GraphQLRequest , InitPayloadResult ) async throws -> SubscriptionSequenceType ,
4545 onMessage: @escaping ( String ) async throws -> Void = { _ in } ,
4646 onOperationComplete: @escaping ( String ) async throws -> Void = { _ in } ,
47- onOperationError: @escaping ( String , [ Error ] ) async throws -> Void = { _, _ in } ,
47+ onOperationError: @escaping ( String , [ Error ] ) async throws -> Void = { _, _ in }
4848 ) {
4949 self . messenger = messenger
5050 self . onInit = onInit
@@ -59,7 +59,7 @@ public actor Server<
5959 /// - Parameter incoming: The client message sequence that the server should react to.
6060 public func listen< A: AsyncSequence & Sendable > ( to incoming: A ) async throws -> Void where A. Element == String {
6161 for try await message in incoming {
62- try await self . onMessage ( message)
62+ try await onMessage ( message)
6363
6464 // Detect and ignore error responses.
6565 if message. starts ( with: " 44 " ) {
@@ -68,13 +68,13 @@ public actor Server<
6868 }
6969
7070 guard let json = message. data ( using: . utf8) else {
71- try await self . error ( . invalidEncoding( ) )
71+ try await error ( . invalidEncoding( ) )
7272 return
7373 }
7474
7575 let request : Request
7676 do {
77- request = try self . decoder. decode ( Request . self, from: json)
77+ request = try decoder. decode ( Request . self, from: json)
7878 } catch {
7979 try await self . error ( . noType( ) )
8080 return
@@ -83,25 +83,25 @@ public actor Server<
8383 // handle incoming message
8484 switch request. type {
8585 case . connectionInit:
86- guard let connectionInitRequest = try ? self . decoder. decode ( ConnectionInitRequest< InitPayload> . self , from: json) else {
87- try await self . error ( . invalidRequestFormat( messageType: . connectionInit) )
86+ guard let connectionInitRequest = try ? decoder. decode ( ConnectionInitRequest< InitPayload> . self , from: json) else {
87+ try await error ( . invalidRequestFormat( messageType: . connectionInit) )
8888 return
8989 }
90- try await self . onConnectionInit ( connectionInitRequest, messenger)
90+ try await onConnectionInit ( connectionInitRequest, messenger)
9191 case . subscribe:
92- guard let subscribeRequest = try ? self . decoder. decode ( SubscribeRequest . self, from: json) else {
93- try await self . error ( . invalidRequestFormat( messageType: . subscribe) )
92+ guard let subscribeRequest = try ? decoder. decode ( SubscribeRequest . self, from: json) else {
93+ try await error ( . invalidRequestFormat( messageType: . subscribe) )
9494 return
9595 }
96- try await self . onSubscribe ( subscribeRequest)
96+ try await onSubscribe ( subscribeRequest)
9797 case . complete:
98- guard let completeRequest = try ? self . decoder. decode ( CompleteRequest . self, from: json) else {
99- try await self . error ( . invalidRequestFormat( messageType: . complete) )
98+ guard let completeRequest = try ? decoder. decode ( CompleteRequest . self, from: json) else {
99+ try await error ( . invalidRequestFormat( messageType: . complete) )
100100 return
101101 }
102- try await self . onOperationComplete ( completeRequest)
102+ try await onOperationComplete ( completeRequest)
103103 default :
104- try await self . error ( . invalidType( ) )
104+ try await error ( . invalidType( ) )
105105 }
106106 }
107107 }
0 commit comments