@@ -118,8 +118,9 @@ public struct SerialFieldExecutionStrategy: QueryFieldExecutionStrategy, Mutatio
118118 path: [ IndexPathElement ] ,
119119 fields: [ String : [ Field ] ]
120120 ) throws -> EventLoopFuture < [ String : Any ] > {
121- return try fields. reduce ( [ String : EventLoopFuture < Any > ] ( ) ) { results, field in
122- var results = results
121+ var results = [ String : EventLoopFuture < Any > ] ( )
122+
123+ try fields. forEach { field in
123124 let fieldASTs = field. value
124125 let fieldPath = path + [ field. key] as [ IndexPathElement ]
125126
@@ -132,8 +133,9 @@ public struct SerialFieldExecutionStrategy: QueryFieldExecutionStrategy, Mutatio
132133 )
133134
134135 results [ field. key] = result. map { $0 ?? Map . null }
135- return results
136- } . flatten ( on: exeContext. eventLoopGroup)
136+ }
137+
138+ return results. flatten ( on: exeContext. eventLoopGroup)
137139 }
138140}
139141
@@ -270,13 +272,13 @@ func execute(
270272 do {
271273 var executeErrors : [ GraphQLError ] = [ ]
272274
273- return try executeOperation (
274- exeContext : context,
275- operation : context . operation ,
276- rootValue : rootValue
277- ) . thenThrowing { data -> Map in
275+ let data = try executeOperation ( exeContext : context ,
276+ operation : context. operation ,
277+ rootValue : rootValue )
278+
279+ return data . thenThrowing { data -> Map in
278280 var dataMap : Map = [ : ]
279- for (key, value) in data {
281+ for (key, value) in data as! [ String : Any ] {
280282 dataMap [ key] = try map ( from: value)
281283 }
282284 var result : [ String : Map ] = [ " data " : dataMap]
@@ -702,7 +704,7 @@ public func resolveField(
702704
703705 exeContext. instrumentation. fieldResolution (
704706 processId: processId ( ) ,
705- threadId: threadId ( ) ,
707+ threadId: threadId ( ) ,
706708 started: resolveFieldStarted,
707709 finished: exeContext. instrumentation. now,
708710 source: source,
@@ -711,7 +713,7 @@ public func resolveField(
711713 info: info,
712714 result: result
713715 )
714-
716+
715717 return try completeValueCatchingError (
716718 exeContext: exeContext,
717719 returnType: returnType,
@@ -871,7 +873,7 @@ func completeValue(
871873 }
872874 }
873875
874- return result. thenThrowing { result -> EventLoopFuture < Any ? > in
876+ return result. thenThrowing { result -> EventLoopFuture < Any ? > in
875877 // If result value is null-ish (nil or .null) then return .null.
876878 guard let result = result, let r = unwrap ( result) else {
877879 return exeContext. eventLoopGroup. next ( ) . newSucceededFuture ( result: nil )
@@ -886,7 +888,7 @@ func completeValue(
886888 info: info,
887889 path: path,
888890 result: r
889- ) . thenThrowing { $0 }
891+ ) . map { $0 }
890892 }
891893
892894 // If field type is a leaf type, Scalar or Enum, serialize to a valid value,
@@ -922,7 +924,7 @@ func completeValue(
922924
923925 // Not reachable. All possible output types have been considered.
924926 throw GraphQLError ( message: " Cannot complete value of unexpected type \" \( returnType) \" . " )
925- }
927+ }
926928 }
927929}
928930
@@ -966,7 +968,7 @@ func completeListValue(
966968
967969 completedResults. append ( completedItem)
968970 }
969-
971+
970972 return completedResults. flatten ( on: exeContext. eventLoopGroup)
971973}
972974
0 commit comments