@@ -19,8 +19,8 @@ public class Server<InitPayload: Equatable & Codable> {
19
19
var auth : ( InitPayload ) throws -> Void = { _ in }
20
20
var onExit : ( ) -> Void = { }
21
21
var onMessage : ( String ) -> Void = { _ in }
22
- var onOperationComplete : ( ) -> Void = { }
23
- var onOperationError : ( ) -> Void = { }
22
+ var onOperationComplete : ( String ) -> Void = { _ in }
23
+ var onOperationError : ( String ) -> Void = { _ in }
24
24
25
25
var initialized = false
26
26
@@ -87,7 +87,7 @@ public class Server<InitPayload: Equatable & Codable> {
87
87
self . error ( . invalidRequestFormat( messageType: . GQL_STOP) )
88
88
return
89
89
}
90
- self . onStop ( stopRequest, messenger )
90
+ self . onOperationComplete ( stopRequest. id )
91
91
case . GQL_CONNECTION_TERMINATE:
92
92
guard let connectionTerminateRequest = try ? self . decoder. decode ( ConnectionTerminateRequest . self, from: json) else {
93
93
self . error ( . invalidRequestFormat( messageType: . GQL_CONNECTION_TERMINATE) )
@@ -121,13 +121,13 @@ public class Server<InitPayload: Equatable & Codable> {
121
121
122
122
/// Define the callback run on the completion a full operation (query/mutation, end of subscription)
123
123
/// - Parameter callback: The callback to assign
124
- public func onOperationComplete( _ callback: @escaping ( ) -> Void ) {
124
+ public func onOperationComplete( _ callback: @escaping ( String ) -> Void ) {
125
125
self . onOperationComplete = callback
126
126
}
127
127
128
128
/// Define the callback to run on error of any full operation (failed query, interrupted subscription)
129
129
/// - Parameter callback: The callback to assign
130
- public func onOperationError( _ callback: @escaping ( ) -> Void ) {
130
+ public func onOperationError( _ callback: @escaping ( String ) -> Void ) {
131
131
self . onOperationError = callback
132
132
}
133
133
@@ -216,14 +216,6 @@ public class Server<InitPayload: Equatable & Codable> {
216
216
}
217
217
}
218
218
219
- private func onStop( _: StopRequest , _ messenger: Messenger ) {
220
- guard initialized else {
221
- self . error ( . notInitialized( ) )
222
- return
223
- }
224
- onOperationComplete ( )
225
- }
226
-
227
219
private func onConnectionTerminate( _: ConnectionTerminateRequest , _ messenger: Messenger ) {
228
220
onExit ( )
229
221
_ = messenger. close ( )
@@ -272,7 +264,7 @@ public class Server<InitPayload: Equatable & Codable> {
272
264
id: id
273
265
) . toJSON ( encoder)
274
266
)
275
- onOperationComplete ( )
267
+ onOperationComplete ( id )
276
268
}
277
269
278
270
/// Send an `error` response through the messenger
@@ -284,7 +276,7 @@ public class Server<InitPayload: Equatable & Codable> {
284
276
id: id
285
277
) . toJSON ( encoder)
286
278
)
287
- onOperationError ( )
279
+ onOperationError ( id )
288
280
}
289
281
290
282
/// Send an `error` response through the messenger
0 commit comments