@@ -273,9 +273,9 @@ func execute(
273273 result: nil
274274 )
275275
276- return eventLoopGroup. next ( ) . newSucceededFuture ( result : GraphQLResult ( errors: [ error] ) )
276+ return eventLoopGroup. next ( ) . makeSucceededFuture ( GraphQLResult ( errors: [ error] ) )
277277 } catch {
278- return eventLoopGroup. next ( ) . newSucceededFuture ( result : GraphQLResult ( errors: [ GraphQLError ( error) ] ) )
278+ return eventLoopGroup. next ( ) . makeSucceededFuture ( GraphQLResult ( errors: [ GraphQLError ( error) ] ) )
279279 }
280280
281281 do {
@@ -285,7 +285,7 @@ func execute(
285285 exeContext: buildContext,
286286 operation: buildContext. operation,
287287 rootValue: rootValue
288- ) . thenThrowing { data -> GraphQLResult in
288+ ) . flatMapThrowing { data -> GraphQLResult in
289289 var dataMap : Map = [ : ]
290290
291291 for (key, value) in data {
@@ -300,12 +300,15 @@ func execute(
300300
301301// executeErrors = buildContext.errors
302302 return result
303- } . mapIfError { error -> GraphQLResult in
303+ } . flatMapError { error -> Future < GraphQLResult > in
304+ let result : GraphQLResult
304305 if let error = error as? GraphQLError {
305- return GraphQLResult ( errors: [ error] )
306+ result = GraphQLResult ( errors: [ error] )
307+ } else {
308+ result = GraphQLResult ( errors: [ GraphQLError ( error) ] )
306309 }
307310
308- return GraphQLResult ( errors : [ GraphQLError ( error ) ] )
311+ return buildContext . eventLoopGroup . next ( ) . makeSucceededFuture ( result )
309312 } . map { result -> GraphQLResult in
310313// instrumentation.operationExecution(
311314// processId: processId(),
@@ -325,9 +328,9 @@ func execute(
325328 return result
326329 }
327330 } catch let error as GraphQLError {
328- return eventLoopGroup. next ( ) . newSucceededFuture ( result : GraphQLResult ( errors: [ error] ) )
331+ return eventLoopGroup. next ( ) . makeSucceededFuture ( GraphQLResult ( errors: [ error] ) )
329332 } catch {
330- return eventLoopGroup. next ( ) . newSucceededFuture ( result : GraphQLResult ( errors: [ GraphQLError ( error) ] ) )
333+ return eventLoopGroup. next ( ) . makeSucceededFuture ( GraphQLResult ( errors: [ GraphQLError ( error) ] ) )
331334 }
332335}
333336
@@ -788,20 +791,20 @@ func completeValueCatchingError(
788791 info: info,
789792 path: path,
790793 result: result
791- ) . mapIfError { error -> Any ? in
794+ ) . flatMapError { error -> EventLoopFuture < Any ? > in
792795 guard let error = error as? GraphQLError else {
793796 fatalError ( )
794797 }
795798 exeContext. append ( error: error)
796- return nil
799+ return exeContext . eventLoopGroup . next ( ) . makeSucceededFuture ( nil )
797800 }
798801
799802 return completed
800803 } catch let error as GraphQLError {
801804 // If `completeValueWithLocatedError` returned abruptly (threw an error),
802805 // log the error and return .null.
803806 exeContext. append ( error: error)
804- return exeContext. eventLoopGroup. next ( ) . newSucceededFuture ( result : nil )
807+ return exeContext. eventLoopGroup. next ( ) . makeSucceededFuture ( nil )
805808 } catch {
806809 fatalError ( )
807810 }
@@ -825,7 +828,7 @@ func completeValueWithLocatedError(
825828 info: info,
826829 path: path,
827830 result: result
828- ) . thenIfErrorThrowing { error -> Any ? in
831+ ) . flatMapErrorThrowing { error -> Any ? in
829832 throw locatedError ( originalError: error, nodes: fieldASTs, path: path)
830833 }
831834 return completed
@@ -881,7 +884,7 @@ func completeValue(
881884 info: info,
882885 path: path,
883886 result: . success( result)
884- ) . thenThrowing { value -> Any ? in
887+ ) . flatMapThrowing { value -> Any ? in
885888 guard let value = value else {
886889 throw GraphQLError ( message: " Cannot return null for non-nullable field \( info. parentType. name) . \( info. fieldName) . " )
887890 }
@@ -893,7 +896,7 @@ func completeValue(
893896 return result. flatMap ( to: Any ? . self) { result -> Future < Any ? > in
894897 // If result value is null-ish (nil or .null) then return .null.
895898 guard let result = result, let r = unwrap ( result) else {
896- return exeContext. eventLoopGroup. next ( ) . newSucceededFuture ( result : nil )
899+ return exeContext. eventLoopGroup. next ( ) . makeSucceededFuture ( nil )
897900 }
898901
899902 // If field type is List, complete each item in the list with the inner type
@@ -911,7 +914,7 @@ func completeValue(
911914 // If field type is a leaf type, Scalar or Enum, serialize to a valid value,
912915 // returning .null if serialization is not possible.
913916 if let returnType = returnType as? GraphQLLeafType {
914- return exeContext. eventLoopGroup. next ( ) . newSucceededFuture ( result : try completeLeafValue ( returnType: returnType, result: r) )
917+ return exeContext. eventLoopGroup. next ( ) . makeSucceededFuture ( try completeLeafValue ( returnType: returnType, result: r) )
915918 }
916919
917920 // If field type is an abstract type, Interface or Union, determine the
@@ -972,7 +975,7 @@ func completeListValue(
972975 // No need to modify the info object containing the path,
973976 // since from here on it is not ever accessed by resolver funcs.
974977 let fieldPath = path. appending ( index)
975- let futureItem = item as? Future < Any ? > ?? exeContext. eventLoopGroup. next ( ) . newSucceededFuture ( result : item)
978+ let futureItem = item as? Future < Any ? > ?? exeContext. eventLoopGroup. next ( ) . makeSucceededFuture ( item)
976979
977980 let completedItem = try completeValueCatchingError (
978981 exeContext: exeContext,
@@ -1161,30 +1164,30 @@ func defaultResolve(
11611164 info: GraphQLResolveInfo
11621165) -> Future < Any ? > {
11631166 guard let source = unwrap ( source) else {
1164- return eventLoopGroup. next ( ) . newSucceededFuture ( result : nil )
1167+ return eventLoopGroup. next ( ) . makeSucceededFuture ( nil )
11651168 }
11661169
11671170 if let subscriptable = source as? KeySubscriptable {
11681171 let value = subscriptable [ info. fieldName]
1169- return eventLoopGroup. next ( ) . newSucceededFuture ( result : value)
1172+ return eventLoopGroup. next ( ) . makeSucceededFuture ( value)
11701173 }
11711174
11721175 guard let encodable = source as? Encodable else {
1173- return eventLoopGroup. next ( ) . newSucceededFuture ( result : nil )
1176+ return eventLoopGroup. next ( ) . makeSucceededFuture ( nil )
11741177 }
11751178
11761179 guard
11771180 let typeInfo = try ? typeInfo ( of: type ( of: encodable) ) ,
11781181 let property = try ? typeInfo. property ( named: info. fieldName)
11791182 else {
1180- return eventLoopGroup. next ( ) . newSucceededFuture ( result : nil )
1183+ return eventLoopGroup. next ( ) . makeSucceededFuture ( nil )
11811184 }
11821185
11831186 guard let value = try ? property. get ( from: encodable) else {
1184- return eventLoopGroup. next ( ) . newSucceededFuture ( result : nil )
1187+ return eventLoopGroup. next ( ) . makeSucceededFuture ( nil )
11851188 }
11861189
1187- return eventLoopGroup. next ( ) . newSucceededFuture ( result : value)
1190+ return eventLoopGroup. next ( ) . makeSucceededFuture ( value)
11881191
11891192// guard let any = try? AnyEncoder().encode(AnyEncodable(encodable)) else {
11901193// return eventLoopGroup.next().newSucceededFuture(result: nil)
0 commit comments