@@ -55,33 +55,33 @@ func subscribe(
5555 operationName: operationName,
5656 subscribeFieldResolver: subscribeFieldResolver
5757 )
58-
59- // For each payload yielded from a subscription, map it over the normal
60- // GraphQL `execute` function, with `payload` as the rootValue.
61- // This implements the "MapSourceToResponseEvent" algorithm described in
62- // the GraphQL specification. The `execute` function provides the
63- // "ExecuteSubscriptionEvent" algorithm, as it is nearly identical to the
64- // "ExecuteQuery" algorithm, for which `execute` is also used.
65- func mapSourceToResponse( payload: Any ) -> EventLoopFuture < GraphQLResult > {
66- return execute (
67- queryStrategy: queryStrategy,
68- mutationStrategy: mutationStrategy,
69- subscriptionStrategy: subscriptionStrategy,
70- instrumentation: instrumentation,
71- schema: schema,
72- documentAST: documentAST,
73- rootValue: payload, // Make payload the root value
74- context: context,
75- eventLoopGroup: eventLoopGroup,
76- variableValues: variableValues,
77- operationName: operationName
78- )
79- }
58+
8059 return sourceFuture. flatMap { subscriptionResult -> EventLoopFuture < SubscriptionResult > in
8160 do {
8261 let subscriptionObserver = try subscriptionResult. get ( )
8362 let eventObserver = subscriptionObserver. map { eventPayload -> GraphQLResult in
84- return try ! mapSourceToResponse ( payload: eventPayload) . wait ( ) // TODO Remove this wait
63+
64+ // For each payload yielded from a subscription, map it over the normal
65+ // GraphQL `execute` function, with `payload` as the rootValue.
66+ // This implements the "MapSourceToResponseEvent" algorithm described in
67+ // the GraphQL specification. The `execute` function provides the
68+ // "ExecuteSubscriptionEvent" algorithm, as it is nearly identical to the
69+ // "ExecuteQuery" algorithm, for which `execute` is also used.
70+ let eventResolved = try execute (
71+ queryStrategy: queryStrategy,
72+ mutationStrategy: mutationStrategy,
73+ subscriptionStrategy: subscriptionStrategy,
74+ instrumentation: instrumentation,
75+ schema: schema,
76+ documentAST: documentAST,
77+ rootValue: eventPayload,
78+ context: context,
79+ eventLoopGroup: eventLoopGroup,
80+ variableValues: variableValues,
81+ operationName: operationName
82+ ) . wait ( ) // TODO remove this wait
83+
84+ return eventResolved
8585 }
8686 // TODO Making a future here feels it indicates a mistake...
8787 return eventLoopGroup. next ( ) . makeSucceededFuture ( SubscriptionResult . success ( eventObserver) )
@@ -151,7 +151,6 @@ func createSourceEventStream(
151151 eventLoopGroup: eventLoopGroup,
152152 rawVariableValues: variableValues,
153153 operationName: operationName
154- // TODO shouldn't we be including the subscribeFieldResolver??
155154 )
156155 return try executeSubscription ( context: exeContext, eventLoopGroup: eventLoopGroup)
157156 } catch let error as GraphQLError {
0 commit comments