Skip to content

Commit 4b036b1

Browse files
committed
all star wars tests passing
1 parent d375bb2 commit 4b036b1

File tree

19 files changed

+1263
-567
lines changed

19 files changed

+1263
-567
lines changed

Sources/GraphQL/Error/GraphQLError.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ public struct GraphQLError : Error {
7373
self.positions = positions
7474
}
7575

76-
if let source = source, !positions.isEmpty {
77-
self.locations = positions.map({ getLocation(source: source, position: $0) })
76+
if let source = self.source, !self.positions.isEmpty {
77+
self.locations = self.positions.map({ getLocation(source: source, position: $0) })
7878
} else {
7979
self.locations = []
8080
}
@@ -108,6 +108,15 @@ extension GraphQLError : MapRepresentable {
108108
dictionary["path"] = path.map({ $0.map }).map
109109
}
110110

111+
if !locations.isEmpty {
112+
dictionary["locations"] = locations.map({
113+
return [
114+
"line": $0.line.map,
115+
"column": $0.column.map
116+
] as Map
117+
}).map
118+
}
119+
111120
return .dictionary(dictionary)
112121
}
113122
}

Sources/GraphQL/Error/LocatedError.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@
33
* GraphQL operation, produce a new GraphQLError aware of the location in the
44
* document responsible for the original Error.
55
*/
6-
func locatedError(originalError: Error?, nodes: [Node], path: [IndexPathElement]) -> GraphQLError {
6+
func locatedError(originalError: Error, nodes: [Node], path: [IndexPathElement]) -> GraphQLError {
77
// Note: this uses a brand-check to support GraphQL errors originating from
88
// other contexts.
99
if let originalError = originalError as? GraphQLError {
1010
return originalError
1111
}
1212

13-
let message = originalError.map({ String(describing: $0) }) ?? "An unknown error occurred."
14-
1513
return GraphQLError(
16-
message: message,
14+
message: String(describing: originalError),
1715
nodes: nodes,
1816
path: path,
1917
originalError: originalError

0 commit comments

Comments
 (0)