Skip to content

Commit 33bb223

Browse files
refactor: Simplify execution result
1 parent d2ac764 commit 33bb223

1 file changed

Lines changed: 2 additions & 15 deletions

File tree

Sources/GraphQL/Execution/Execute.swift

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -183,26 +183,13 @@ public func execute(
183183
}
184184

185185
do {
186-
// var executeErrors: [GraphQLError] = []
187186
let data = try await executeOperation(
188187
exeContext: buildContext,
189188
operation: buildContext.operation,
190189
rootValue: rootValue
191190
)
192-
var dataMap: Map = [:]
193-
194-
for (key, value) in data {
195-
dataMap[key] = try map(from: value)
196-
}
197-
198-
var result: GraphQLResult = .init(data: dataMap)
199-
200-
if !buildContext.errors.isEmpty {
201-
result.errors = buildContext.errors
202-
}
203-
204-
// executeErrors = buildContext.errors
205-
return result
191+
let dataMap = try Map(data.mapValues { try map(from: $0) })
192+
return GraphQLResult(data: dataMap, errors: buildContext.errors)
206193
} catch let error as GraphQLError {
207194
return GraphQLResult(errors: [error])
208195
} catch {

0 commit comments

Comments
 (0)