@@ -37,7 +37,6 @@ func subscribe(
37
37
operationName: String ? = nil
38
38
) -> EventLoopFuture < SubscriptionResult > {
39
39
40
-
41
40
let sourceFuture = createSourceEventStream (
42
41
queryStrategy: queryStrategy,
43
42
mutationStrategy: mutationStrategy,
@@ -252,7 +251,7 @@ func executeSubscription(
252
251
return SourceEventStreamResult ( errors: context. errors)
253
252
} else if let error = resolved as? GraphQLError {
254
253
return SourceEventStreamResult ( errors: [ error] )
255
- } else if let observable = resolved as? SourceEventStreamObservable {
254
+ } else if let observable = resolved as? SourceEventObservable {
256
255
return SourceEventStreamResult ( observable: observable)
257
256
} else if resolved == nil {
258
257
return SourceEventStreamResult ( errors: [
@@ -262,36 +261,23 @@ func executeSubscription(
262
261
let resolvedObj = resolved as AnyObject
263
262
return SourceEventStreamResult ( errors: [
264
263
GraphQLError (
265
- message: " Subscription field resolver must return SourceEventStreamObservable . Received: ' \( resolvedObj) ' "
264
+ message: " Subscription field resolver must return SourceEventObservable . Received: ' \( resolvedObj) ' "
266
265
)
267
266
] )
268
267
}
269
268
}
270
269
}
271
270
272
- /// SubscriptionResult wraps the observable and error data returned by the subscribe request.
273
- public struct SubscriptionResult {
274
- public let observable : SubscriptionObservable ?
275
- public let errors : [ GraphQLError ]
276
-
277
- public init ( observable: SubscriptionObservable ? = nil , errors: [ GraphQLError ] = [ ] ) {
278
- self . observable = observable
279
- self . errors = errors
280
- }
281
- }
282
- /// SubscriptionObservable represents an event stream of fully resolved GraphQL subscription results. It can be used to add subscribers to this stream
283
- public typealias SubscriptionObservable = Observable < Future < GraphQLResult > >
284
-
285
271
struct SourceEventStreamResult {
286
- public let observable : SourceEventStreamObservable ?
272
+ public let observable : SourceEventObservable ?
287
273
public let errors : [ GraphQLError ]
288
274
289
- public init ( observable: SourceEventStreamObservable ? = nil , errors: [ GraphQLError ] = [ ] ) {
275
+ public init ( observable: SourceEventObservable ? = nil , errors: [ GraphQLError ] = [ ] ) {
290
276
self . observable = observable
291
277
self . errors = errors
292
278
}
293
279
}
294
- /// Observables MUST be declared as 'Any' due to Swift not having covariant generic support. Resolvers should handle type checks.
295
- typealias SourceEventStreamObservable = Observable < Any >
296
-
297
280
281
+ // Subscription resolvers MUST return observables that are declared as 'Any' due to Swift not having covariant generic support for type
282
+ // checking. Normal resolvers for subscription fields should handle type casting, same as resolvers for query fields.
283
+ typealias SourceEventObservable = Observable < Any >
0 commit comments