@@ -28,7 +28,7 @@ public struct GraphQLError: Error, Codable {
28
28
*
29
29
* Appears in the result of `description`.
30
30
*/
31
- public let locations : [ SourceLocation ]
31
+ public let locations : [ SourceLocation ] ?
32
32
33
33
/**
34
34
* An array describing the index path into the execution response which
@@ -118,7 +118,7 @@ public struct GraphQLError: Error, Codable {
118
118
public init ( from decoder: Decoder ) throws {
119
119
let container = try decoder. container ( keyedBy: CodingKeys . self)
120
120
message = try container. decode ( String . self, forKey: . message)
121
- locations = try container. decode ( [ SourceLocation] ? . self, forKey: . locations) ?? [ ]
121
+ locations = ( try ? container. decode ( [ SourceLocation] ? . self, forKey: . locations) ) ?? [ ]
122
122
path = try container. decode ( IndexPath . self, forKey: . path)
123
123
}
124
124
@@ -127,7 +127,7 @@ public struct GraphQLError: Error, Codable {
127
127
128
128
try container. encode ( message, forKey: . message)
129
129
130
- if !locations. isEmpty {
130
+ if !( locations? . isEmpty ?? true ) {
131
131
try container. encode ( locations, forKey: . locations)
132
132
}
133
133
@@ -166,7 +166,7 @@ public struct IndexPath: Codable {
166
166
167
167
public init ( from decoder: Decoder ) throws {
168
168
var container = try decoder. unkeyedContainer ( )
169
- elements = try container. decode ( [ IndexPathValue ] . self)
169
+ elements = ( try ? container. decode ( [ IndexPathValue ] . self) ) ?? [ ]
170
170
}
171
171
172
172
public func encode( to encoder: Encoder ) throws {
0 commit comments