Skip to content

Commit f8d3563

Browse files
gh-action-runnergh-action-runner
authored andcommitted
Squashed 'apollo-ios/' changes from e98e9d3b..129c16a1
129c16a1 fix: InputObject GraphQLNullable subscript (#596) git-subtree-dir: apollo-ios git-subtree-split: 129c16a14210168665ea5f41e8060f8528f99cdd
1 parent 77ffd62 commit f8d3563

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Sources/ApolloAPI/SchemaTypes/InputObject.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,23 @@ public struct InputDict: GraphQLOperationVariableValue, Hashable {
3030

3131
public var _jsonEncodableValue: (any JSONEncodable)? { data._jsonEncodableObject }
3232

33+
@_disfavoredOverload
3334
public subscript<T: GraphQLOperationVariableValue>(key: String) -> T {
3435
get { data[key] as! T }
3536
set { data[key] = newValue }
3637
}
3738

39+
public subscript<T: GraphQLOperationVariableValue>(key: String) -> GraphQLNullable<T> {
40+
get {
41+
if let value = data[key] {
42+
return value as! GraphQLNullable<T>
43+
}
44+
45+
return .none
46+
}
47+
set { data[key] = newValue }
48+
}
49+
3850
public static func == (lhs: InputDict, rhs: InputDict) -> Bool {
3951
lhs.data._jsonEncodableValue?._jsonValue == rhs.data._jsonEncodableValue?._jsonValue
4052
}

0 commit comments

Comments
 (0)