From fe577cbdd53dc9dc73985a4f1b0fd66f8b4b6ac7 Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Thu, 4 Aug 2022 06:33:33 -0700 Subject: [PATCH] update swift graphql schema --- .../Services/DataService/GQLSchema.swift | 416 ++++++++++++++++++ 1 file changed, 416 insertions(+) diff --git a/apple/OmnivoreKit/Sources/Services/DataService/GQLSchema.swift b/apple/OmnivoreKit/Sources/Services/DataService/GQLSchema.swift index 5cde5af97..f34630594 100644 --- a/apple/OmnivoreKit/Sources/Services/DataService/GQLSchema.swift +++ b/apple/OmnivoreKit/Sources/Services/DataService/GQLSchema.swift @@ -9729,6 +9729,7 @@ extension Objects { let sharedArticle: [String: Unions.SharedArticleResult] let subscriptions: [String: Unions.SubscriptionsResult] let typeaheadSearch: [String: Unions.TypeaheadSearchResult] + let updatesSince: [String: Unions.UpdatesSinceResult] let user: [String: Unions.UserResult] let users: [String: Unions.UsersResult] let validateUsername: [String: Bool] @@ -9825,6 +9826,10 @@ extension Objects.Query: Decodable { if let value = try container.decode(Unions.TypeaheadSearchResult?.self, forKey: codingKey) { map.set(key: field, hash: alias, value: value as Any) } + case "updatesSince": + if let value = try container.decode(Unions.UpdatesSinceResult?.self, forKey: codingKey) { + map.set(key: field, hash: alias, value: value as Any) + } case "user": if let value = try container.decode(Unions.UserResult?.self, forKey: codingKey) { map.set(key: field, hash: alias, value: value as Any) @@ -9873,6 +9878,7 @@ extension Objects.Query: Decodable { sharedArticle = map["sharedArticle"] subscriptions = map["subscriptions"] typeaheadSearch = map["typeaheadSearch"] + updatesSince = map["updatesSince"] user = map["user"] users = map["users"] validateUsername = map["validateUsername"] @@ -10217,6 +10223,25 @@ extension Fields where TypeLock == Objects.Query { } } + func updatesSince(after: OptionalArgument = .absent(), first: OptionalArgument = .absent(), since: DateTime, selection: Selection) throws -> Type { + let field = GraphQLField.composite( + name: "updatesSince", + arguments: [Argument(name: "after", type: "String", value: after), Argument(name: "first", type: "Int", value: first), Argument(name: "since", type: "Date!", value: since)], + selection: selection.selection + ) + select(field) + + switch response { + case let .decoding(data): + if let data = data.updatesSince[field.alias!] { + return try selection.decode(data: data) + } + throw HttpError.badpayload + case .mocking: + return selection.mock() + } + } + func user(userId: OptionalArgument = .absent(), username: OptionalArgument = .absent(), selection: Selection) throws -> Type { let field = GraphQLField.composite( name: "user", @@ -14366,6 +14391,141 @@ extension Selection where TypeLock == Never, Type == Never { typealias SubscriptionsSuccess = Selection } +extension Objects { + struct SyncUpdatedItemEdge { + let __typename: TypeName = .syncUpdatedItemEdge + let cursor: [String: String] + let itemId: [String: String] + let node: [String: Objects.SearchItem] + let updateReason: [String: Enums.UpdateReason] + + enum TypeName: String, Codable { + case syncUpdatedItemEdge = "SyncUpdatedItemEdge" + } + } +} + +extension Objects.SyncUpdatedItemEdge: Decodable { + init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DynamicCodingKeys.self) + + var map = HashMap() + for codingKey in container.allKeys { + if codingKey.isTypenameKey { continue } + + let alias = codingKey.stringValue + let field = GraphQLField.getFieldNameFromAlias(alias) + + switch field { + case "cursor": + if let value = try container.decode(String?.self, forKey: codingKey) { + map.set(key: field, hash: alias, value: value as Any) + } + case "itemId": + if let value = try container.decode(String?.self, forKey: codingKey) { + map.set(key: field, hash: alias, value: value as Any) + } + case "node": + if let value = try container.decode(Objects.SearchItem?.self, forKey: codingKey) { + map.set(key: field, hash: alias, value: value as Any) + } + case "updateReason": + if let value = try container.decode(Enums.UpdateReason?.self, forKey: codingKey) { + map.set(key: field, hash: alias, value: value as Any) + } + default: + throw DecodingError.dataCorrupted( + DecodingError.Context( + codingPath: decoder.codingPath, + debugDescription: "Unknown key \(field)." + ) + ) + } + } + + cursor = map["cursor"] + itemId = map["itemId"] + node = map["node"] + updateReason = map["updateReason"] + } +} + +extension Fields where TypeLock == Objects.SyncUpdatedItemEdge { + func cursor() throws -> String { + let field = GraphQLField.leaf( + name: "cursor", + arguments: [] + ) + select(field) + + switch response { + case let .decoding(data): + if let data = data.cursor[field.alias!] { + return data + } + throw HttpError.badpayload + case .mocking: + return String.mockValue + } + } + + func itemId() throws -> String { + let field = GraphQLField.leaf( + name: "itemID", + arguments: [] + ) + select(field) + + switch response { + case let .decoding(data): + if let data = data.itemId[field.alias!] { + return data + } + throw HttpError.badpayload + case .mocking: + return String.mockValue + } + } + + func node(selection: Selection) throws -> Type { + let field = GraphQLField.composite( + name: "node", + arguments: [], + selection: selection.selection + ) + select(field) + + switch response { + case let .decoding(data): + return try selection.decode(data: data.node[field.alias!]) + case .mocking: + return selection.mock() + } + } + + func updateReason() throws -> Enums.UpdateReason { + let field = GraphQLField.leaf( + name: "updateReason", + arguments: [] + ) + select(field) + + switch response { + case let .decoding(data): + if let data = data.updateReason[field.alias!] { + return data + } + throw HttpError.badpayload + case .mocking: + return Enums.UpdateReason.allCases.first! + } + } +} + +extension Selection where TypeLock == Never, Type == Never { + typealias SyncUpdatedItemEdge = Selection +} + extension Objects { struct TypeaheadSearchError { let __typename: TypeName = .typeaheadSearchError @@ -15963,6 +16123,162 @@ extension Selection where TypeLock == Never, Type == Never { typealias UpdateUserSuccess = Selection } +extension Objects { + struct UpdatesSinceError { + let __typename: TypeName = .updatesSinceError + let errorCodes: [String: [Enums.UpdatesSinceErrorCode]] + + enum TypeName: String, Codable { + case updatesSinceError = "UpdatesSinceError" + } + } +} + +extension Objects.UpdatesSinceError: Decodable { + init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DynamicCodingKeys.self) + + var map = HashMap() + for codingKey in container.allKeys { + if codingKey.isTypenameKey { continue } + + let alias = codingKey.stringValue + let field = GraphQLField.getFieldNameFromAlias(alias) + + switch field { + case "errorCodes": + if let value = try container.decode([Enums.UpdatesSinceErrorCode]?.self, forKey: codingKey) { + map.set(key: field, hash: alias, value: value as Any) + } + default: + throw DecodingError.dataCorrupted( + DecodingError.Context( + codingPath: decoder.codingPath, + debugDescription: "Unknown key \(field)." + ) + ) + } + } + + errorCodes = map["errorCodes"] + } +} + +extension Fields where TypeLock == Objects.UpdatesSinceError { + func errorCodes() throws -> [Enums.UpdatesSinceErrorCode] { + let field = GraphQLField.leaf( + name: "errorCodes", + arguments: [] + ) + select(field) + + switch response { + case let .decoding(data): + if let data = data.errorCodes[field.alias!] { + return data + } + throw HttpError.badpayload + case .mocking: + return [] + } + } +} + +extension Selection where TypeLock == Never, Type == Never { + typealias UpdatesSinceError = Selection +} + +extension Objects { + struct UpdatesSinceSuccess { + let __typename: TypeName = .updatesSinceSuccess + let edges: [String: [Objects.SyncUpdatedItemEdge]] + let pageInfo: [String: Objects.PageInfo] + + enum TypeName: String, Codable { + case updatesSinceSuccess = "UpdatesSinceSuccess" + } + } +} + +extension Objects.UpdatesSinceSuccess: Decodable { + init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DynamicCodingKeys.self) + + var map = HashMap() + for codingKey in container.allKeys { + if codingKey.isTypenameKey { continue } + + let alias = codingKey.stringValue + let field = GraphQLField.getFieldNameFromAlias(alias) + + switch field { + case "edges": + if let value = try container.decode([Objects.SyncUpdatedItemEdge]?.self, forKey: codingKey) { + map.set(key: field, hash: alias, value: value as Any) + } + case "pageInfo": + if let value = try container.decode(Objects.PageInfo?.self, forKey: codingKey) { + map.set(key: field, hash: alias, value: value as Any) + } + default: + throw DecodingError.dataCorrupted( + DecodingError.Context( + codingPath: decoder.codingPath, + debugDescription: "Unknown key \(field)." + ) + ) + } + } + + edges = map["edges"] + pageInfo = map["pageInfo"] + } +} + +extension Fields where TypeLock == Objects.UpdatesSinceSuccess { + func edges(selection: Selection) throws -> Type { + let field = GraphQLField.composite( + name: "edges", + arguments: [], + selection: selection.selection + ) + select(field) + + switch response { + case let .decoding(data): + if let data = data.edges[field.alias!] { + return try selection.decode(data: data) + } + throw HttpError.badpayload + case .mocking: + return selection.mock() + } + } + + func pageInfo(selection: Selection) throws -> Type { + let field = GraphQLField.composite( + name: "pageInfo", + arguments: [], + selection: selection.selection + ) + select(field) + + switch response { + case let .decoding(data): + if let data = data.pageInfo[field.alias!] { + return try selection.decode(data: data) + } + throw HttpError.badpayload + case .mocking: + return selection.mock() + } + } +} + +extension Selection where TypeLock == Never, Type == Never { + typealias UpdatesSinceSuccess = Selection +} + extension Objects { struct UploadFileRequestError { let __typename: TypeName = .uploadFileRequestError @@ -22023,6 +22339,86 @@ extension Selection where TypeLock == Never, Type == Never { typealias UpdateUserResult = Selection } +extension Unions { + struct UpdatesSinceResult { + let __typename: TypeName + let edges: [String: [Objects.SyncUpdatedItemEdge]] + let errorCodes: [String: [Enums.UpdatesSinceErrorCode]] + let pageInfo: [String: Objects.PageInfo] + + enum TypeName: String, Codable { + case updatesSinceError = "UpdatesSinceError" + case updatesSinceSuccess = "UpdatesSinceSuccess" + } + } +} + +extension Unions.UpdatesSinceResult: Decodable { + init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: DynamicCodingKeys.self) + + var map = HashMap() + for codingKey in container.allKeys { + if codingKey.isTypenameKey { continue } + + let alias = codingKey.stringValue + let field = GraphQLField.getFieldNameFromAlias(alias) + + switch field { + case "edges": + if let value = try container.decode([Objects.SyncUpdatedItemEdge]?.self, forKey: codingKey) { + map.set(key: field, hash: alias, value: value as Any) + } + case "errorCodes": + if let value = try container.decode([Enums.UpdatesSinceErrorCode]?.self, forKey: codingKey) { + map.set(key: field, hash: alias, value: value as Any) + } + case "pageInfo": + if let value = try container.decode(Objects.PageInfo?.self, forKey: codingKey) { + map.set(key: field, hash: alias, value: value as Any) + } + default: + throw DecodingError.dataCorrupted( + DecodingError.Context( + codingPath: decoder.codingPath, + debugDescription: "Unknown key \(field)." + ) + ) + } + } + + __typename = try container.decode(TypeName.self, forKey: DynamicCodingKeys(stringValue: "__typename")!) + + edges = map["edges"] + errorCodes = map["errorCodes"] + pageInfo = map["pageInfo"] + } +} + +extension Fields where TypeLock == Unions.UpdatesSinceResult { + func on(updatesSinceError: Selection, updatesSinceSuccess: Selection) throws -> Type { + select([GraphQLField.fragment(type: "UpdatesSinceError", selection: updatesSinceError.selection), GraphQLField.fragment(type: "UpdatesSinceSuccess", selection: updatesSinceSuccess.selection)]) + + switch response { + case let .decoding(data): + switch data.__typename { + case .updatesSinceError: + let data = Objects.UpdatesSinceError(errorCodes: data.errorCodes) + return try updatesSinceError.decode(data: data) + case .updatesSinceSuccess: + let data = Objects.UpdatesSinceSuccess(edges: data.edges, pageInfo: data.pageInfo) + return try updatesSinceSuccess.decode(data: data) + } + case .mocking: + return updatesSinceError.mock() + } + } +} + +extension Selection where TypeLock == Never, Type == Never { + typealias UpdatesSinceResult = Selection +} + extension Unions { struct UploadFileRequestResult { let __typename: TypeName @@ -22466,6 +22862,8 @@ extension Enums { extension Enums { /// ArticleSavingRequestStatus enum ArticleSavingRequestStatus: String, CaseIterable, Codable { + case deleted = "DELETED" + case failed = "FAILED" case processing = "PROCESSING" @@ -23137,6 +23535,17 @@ extension Enums { } } +extension Enums { + /// UpdateReason + enum UpdateReason: String, CaseIterable, Codable { + case created = "CREATED" + + case deleted = "DELETED" + + case updated = "UPDATED" + } +} + extension Enums { /// UpdateReminderErrorCode enum UpdateReminderErrorCode: String, CaseIterable, Codable { @@ -23185,6 +23594,13 @@ extension Enums { } } +extension Enums { + /// UpdatesSinceErrorCode + enum UpdatesSinceErrorCode: String, CaseIterable, Codable { + case unauthorized = "UNAUTHORIZED" + } +} + extension Enums { /// UploadFileRequestErrorCode enum UploadFileRequestErrorCode: String, CaseIterable, Codable {