Skip to content

Commit 8de2349

Browse files
refactor: Simplify execution result
1 parent e4818b7 commit 8de2349

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
@@ -201,26 +201,13 @@ public func execute(
201201
}
202202

203203
do {
204-
// var executeErrors: [GraphQLError] = []
205204
let data = try await executeOperation(
206205
exeContext: buildContext,
207206
operation: buildContext.operation,
208207
rootValue: rootValue
209208
)
210-
var dataMap: Map = [:]
211-
212-
for (key, value) in data {
213-
dataMap[key] = try map(from: value)
214-
}
215-
216-
var result: GraphQLResult = .init(data: dataMap)
217-
218-
if !buildContext.errors.isEmpty {
219-
result.errors = buildContext.errors
220-
}
221-
222-
// executeErrors = buildContext.errors
223-
return result
209+
let dataMap = try Map(data.mapValues { try map(from: $0) })
210+
return GraphQLResult(data: dataMap, errors: buildContext.errors)
224211
} catch let error as GraphQLError {
225212
return GraphQLResult(errors: [error])
226213
} catch {

0 commit comments

Comments
 (0)