@@ -118,8 +118,9 @@ public struct SerialFieldExecutionStrategy: QueryFieldExecutionStrategy, Mutatio
118
118
path: [ IndexPathElement ] ,
119
119
fields: [ String : [ Field ] ]
120
120
) 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
123
124
let fieldASTs = field. value
124
125
let fieldPath = path + [ field. key] as [ IndexPathElement ]
125
126
@@ -132,8 +133,9 @@ public struct SerialFieldExecutionStrategy: QueryFieldExecutionStrategy, Mutatio
132
133
)
133
134
134
135
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)
137
139
}
138
140
}
139
141
@@ -270,13 +272,13 @@ func execute(
270
272
do {
271
273
var executeErrors : [ GraphQLError ] = [ ]
272
274
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
278
280
var dataMap : Map = [ : ]
279
- for (key, value) in data {
281
+ for (key, value) in data as! [ String : Any ] {
280
282
dataMap [ key] = try map ( from: value)
281
283
}
282
284
var result : [ String : Map ] = [ " data " : dataMap]
@@ -702,7 +704,7 @@ public func resolveField(
702
704
703
705
exeContext. instrumentation. fieldResolution (
704
706
processId: processId ( ) ,
705
- threadId: threadId ( ) ,
707
+ threadId: threadId ( ) ,
706
708
started: resolveFieldStarted,
707
709
finished: exeContext. instrumentation. now,
708
710
source: source,
@@ -711,7 +713,7 @@ public func resolveField(
711
713
info: info,
712
714
result: result
713
715
)
714
-
716
+
715
717
return try completeValueCatchingError (
716
718
exeContext: exeContext,
717
719
returnType: returnType,
@@ -871,7 +873,7 @@ func completeValue(
871
873
}
872
874
}
873
875
874
- return result. thenThrowing { result -> EventLoopFuture < Any ? > in
876
+ return result. thenThrowing { result -> EventLoopFuture < Any ? > in
875
877
// If result value is null-ish (nil or .null) then return .null.
876
878
guard let result = result, let r = unwrap ( result) else {
877
879
return exeContext. eventLoopGroup. next ( ) . newSucceededFuture ( result: nil )
@@ -886,7 +888,7 @@ func completeValue(
886
888
info: info,
887
889
path: path,
888
890
result: r
889
- ) . thenThrowing { $0 }
891
+ ) . map { $0 }
890
892
}
891
893
892
894
// If field type is a leaf type, Scalar or Enum, serialize to a valid value,
@@ -922,7 +924,7 @@ func completeValue(
922
924
923
925
// Not reachable. All possible output types have been considered.
924
926
throw GraphQLError ( message: " Cannot complete value of unexpected type \" \( returnType) \" . " )
925
- }
927
+ }
926
928
}
927
929
}
928
930
@@ -966,7 +968,7 @@ func completeListValue(
966
968
967
969
completedResults. append ( completedItem)
968
970
}
969
-
971
+
970
972
return completedResults. flatten ( on: exeContext. eventLoopGroup)
971
973
}
972
974
0 commit comments