File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Sources/GraphQL/Utilities Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ extension Collection {
2828
2929extension Dictionary where Value : FutureType {
3030 func flatten( on eventLoopGroup: EventLoopGroup ) -> Future < [ Key : Value . Expectation ] > {
31+ let queue = DispatchQueue ( label: " org.graphQL.elementQueue " )
3132 var elements : [ Key : Value . Expectation ] = [ : ]
3233
3334 guard self . count > 0 else {
@@ -39,10 +40,13 @@ extension Dictionary where Value : FutureType {
3940
4041 for (key, value) in self {
4142 value. whenSuccess { expectation in
42- elements [ key] = expectation
43-
44- if elements. count == self . count {
45- promise. succeed ( elements)
43+ // Control access to elements to avoid thread conflicts
44+ queue. async {
45+ elements [ key] = expectation
46+
47+ if elements. count == self . count {
48+ promise. succeed ( elements)
49+ }
4650 }
4751 }
4852
You can’t perform that action at this time.
0 commit comments