@@ -273,9 +273,9 @@ func execute(
273
273
result: nil
274
274
)
275
275
276
- return eventLoopGroup. next ( ) . newSucceededFuture ( result : GraphQLResult ( errors: [ error] ) )
276
+ return eventLoopGroup. next ( ) . makeSucceededFuture ( GraphQLResult ( errors: [ error] ) )
277
277
} catch {
278
- return eventLoopGroup. next ( ) . newSucceededFuture ( result : GraphQLResult ( errors: [ GraphQLError ( error) ] ) )
278
+ return eventLoopGroup. next ( ) . makeSucceededFuture ( GraphQLResult ( errors: [ GraphQLError ( error) ] ) )
279
279
}
280
280
281
281
do {
@@ -285,7 +285,7 @@ func execute(
285
285
exeContext: buildContext,
286
286
operation: buildContext. operation,
287
287
rootValue: rootValue
288
- ) . thenThrowing { data -> GraphQLResult in
288
+ ) . flatMapThrowing { data -> GraphQLResult in
289
289
var dataMap : Map = [ : ]
290
290
291
291
for (key, value) in data {
@@ -300,12 +300,15 @@ func execute(
300
300
301
301
// executeErrors = buildContext.errors
302
302
return result
303
- } . mapIfError { error -> GraphQLResult in
303
+ } . flatMapError { error -> Future < GraphQLResult > in
304
+ let result : GraphQLResult
304
305
if let error = error as? GraphQLError {
305
- return GraphQLResult ( errors: [ error] )
306
+ result = GraphQLResult ( errors: [ error] )
307
+ } else {
308
+ result = GraphQLResult ( errors: [ GraphQLError ( error) ] )
306
309
}
307
310
308
- return GraphQLResult ( errors : [ GraphQLError ( error ) ] )
311
+ return buildContext . eventLoopGroup . next ( ) . makeSucceededFuture ( result )
309
312
} . map { result -> GraphQLResult in
310
313
// instrumentation.operationExecution(
311
314
// processId: processId(),
@@ -325,9 +328,9 @@ func execute(
325
328
return result
326
329
}
327
330
} catch let error as GraphQLError {
328
- return eventLoopGroup. next ( ) . newSucceededFuture ( result : GraphQLResult ( errors: [ error] ) )
331
+ return eventLoopGroup. next ( ) . makeSucceededFuture ( GraphQLResult ( errors: [ error] ) )
329
332
} catch {
330
- return eventLoopGroup. next ( ) . newSucceededFuture ( result : GraphQLResult ( errors: [ GraphQLError ( error) ] ) )
333
+ return eventLoopGroup. next ( ) . makeSucceededFuture ( GraphQLResult ( errors: [ GraphQLError ( error) ] ) )
331
334
}
332
335
}
333
336
@@ -788,20 +791,20 @@ func completeValueCatchingError(
788
791
info: info,
789
792
path: path,
790
793
result: result
791
- ) . mapIfError { error -> Any ? in
794
+ ) . flatMapError { error -> EventLoopFuture < Any ? > in
792
795
guard let error = error as? GraphQLError else {
793
796
fatalError ( )
794
797
}
795
798
exeContext. append ( error: error)
796
- return nil
799
+ return exeContext . eventLoopGroup . next ( ) . makeSucceededFuture ( nil )
797
800
}
798
801
799
802
return completed
800
803
} catch let error as GraphQLError {
801
804
// If `completeValueWithLocatedError` returned abruptly (threw an error),
802
805
// log the error and return .null.
803
806
exeContext. append ( error: error)
804
- return exeContext. eventLoopGroup. next ( ) . newSucceededFuture ( result : nil )
807
+ return exeContext. eventLoopGroup. next ( ) . makeSucceededFuture ( nil )
805
808
} catch {
806
809
fatalError ( )
807
810
}
@@ -825,7 +828,7 @@ func completeValueWithLocatedError(
825
828
info: info,
826
829
path: path,
827
830
result: result
828
- ) . thenIfErrorThrowing { error -> Any ? in
831
+ ) . flatMapErrorThrowing { error -> Any ? in
829
832
throw locatedError ( originalError: error, nodes: fieldASTs, path: path)
830
833
}
831
834
return completed
@@ -881,7 +884,7 @@ func completeValue(
881
884
info: info,
882
885
path: path,
883
886
result: . success( result)
884
- ) . thenThrowing { value -> Any ? in
887
+ ) . flatMapThrowing { value -> Any ? in
885
888
guard let value = value else {
886
889
throw GraphQLError ( message: " Cannot return null for non-nullable field \( info. parentType. name) . \( info. fieldName) . " )
887
890
}
@@ -893,7 +896,7 @@ func completeValue(
893
896
return result. flatMap ( to: Any ? . self) { result -> Future < Any ? > in
894
897
// If result value is null-ish (nil or .null) then return .null.
895
898
guard let result = result, let r = unwrap ( result) else {
896
- return exeContext. eventLoopGroup. next ( ) . newSucceededFuture ( result : nil )
899
+ return exeContext. eventLoopGroup. next ( ) . makeSucceededFuture ( nil )
897
900
}
898
901
899
902
// If field type is List, complete each item in the list with the inner type
@@ -911,7 +914,7 @@ func completeValue(
911
914
// If field type is a leaf type, Scalar or Enum, serialize to a valid value,
912
915
// returning .null if serialization is not possible.
913
916
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) )
915
918
}
916
919
917
920
// If field type is an abstract type, Interface or Union, determine the
@@ -972,7 +975,7 @@ func completeListValue(
972
975
// No need to modify the info object containing the path,
973
976
// since from here on it is not ever accessed by resolver funcs.
974
977
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)
976
979
977
980
let completedItem = try completeValueCatchingError (
978
981
exeContext: exeContext,
@@ -1161,30 +1164,30 @@ func defaultResolve(
1161
1164
info: GraphQLResolveInfo
1162
1165
) -> Future < Any ? > {
1163
1166
guard let source = unwrap ( source) else {
1164
- return eventLoopGroup. next ( ) . newSucceededFuture ( result : nil )
1167
+ return eventLoopGroup. next ( ) . makeSucceededFuture ( nil )
1165
1168
}
1166
1169
1167
1170
if let subscriptable = source as? KeySubscriptable {
1168
1171
let value = subscriptable [ info. fieldName]
1169
- return eventLoopGroup. next ( ) . newSucceededFuture ( result : value)
1172
+ return eventLoopGroup. next ( ) . makeSucceededFuture ( value)
1170
1173
}
1171
1174
1172
1175
guard let encodable = source as? Encodable else {
1173
- return eventLoopGroup. next ( ) . newSucceededFuture ( result : nil )
1176
+ return eventLoopGroup. next ( ) . makeSucceededFuture ( nil )
1174
1177
}
1175
1178
1176
1179
guard
1177
1180
let typeInfo = try ? typeInfo ( of: type ( of: encodable) ) ,
1178
1181
let property = try ? typeInfo. property ( named: info. fieldName)
1179
1182
else {
1180
- return eventLoopGroup. next ( ) . newSucceededFuture ( result : nil )
1183
+ return eventLoopGroup. next ( ) . makeSucceededFuture ( nil )
1181
1184
}
1182
1185
1183
1186
guard let value = try ? property. get ( from: encodable) else {
1184
- return eventLoopGroup. next ( ) . newSucceededFuture ( result : nil )
1187
+ return eventLoopGroup. next ( ) . makeSucceededFuture ( nil )
1185
1188
}
1186
1189
1187
- return eventLoopGroup. next ( ) . newSucceededFuture ( result : value)
1190
+ return eventLoopGroup. next ( ) . makeSucceededFuture ( value)
1188
1191
1189
1192
// guard let any = try? AnyEncoder().encode(AnyEncodable(encodable)) else {
1190
1193
// return eventLoopGroup.next().newSucceededFuture(result: nil)
0 commit comments