Update GQL schema adding labels to highlights

This commit is contained in:
Jackson Harper 2022-11-28 15:33:58 +08:00
parent 4f1b4e523c
commit 179d791a73

View file

@ -6315,6 +6315,7 @@ extension Objects {
let highlightPositionAnchorIndex: [String: Int]
let highlightPositionPercent: [String: Double]
let id: [String: String]
let labels: [String: [Objects.Label]]
let patch: [String: String]
let prefix: [String: String]
let quote: [String: String]
@ -6368,6 +6369,10 @@ extension Objects.Highlight: Decodable {
if let value = try container.decode(String?.self, forKey: codingKey) {
map.set(key: field, hash: alias, value: value as Any)
}
case "labels":
if let value = try container.decode([Objects.Label]?.self, forKey: codingKey) {
map.set(key: field, hash: alias, value: value as Any)
}
case "patch":
if let value = try container.decode(String?.self, forKey: codingKey) {
map.set(key: field, hash: alias, value: value as Any)
@ -6424,6 +6429,7 @@ extension Objects.Highlight: Decodable {
highlightPositionAnchorIndex = map["highlightPositionAnchorIndex"]
highlightPositionPercent = map["highlightPositionPercent"]
id = map["id"]
labels = map["labels"]
patch = map["patch"]
prefix = map["prefix"]
quote = map["quote"]
@ -6537,6 +6543,22 @@ extension Fields where TypeLock == Objects.Highlight {
}
}
func labels<Type>(selection: Selection<Type, [Objects.Label]?>) throws -> Type {
let field = GraphQLField.composite(
name: "labels",
arguments: [],
selection: selection.selection
)
select(field)
switch response {
case let .decoding(data):
return try selection.decode(data: data.labels[field.alias!])
case .mocking:
return selection.mock()
}
}
func patch() throws -> String {
let field = GraphQLField.leaf(
name: "patch",