diff --git a/API/Package.swift b/API/Package.swift index ca4f249..eec527a 100644 --- a/API/Package.swift +++ b/API/Package.swift @@ -20,6 +20,7 @@ let package = Package( .target( name: "API", dependencies: [ + .product(name: "Apollo", package: "apollo-ios"), .product(name: "ApolloAPI", package: "apollo-ios"), ], path: "./Sources" diff --git a/API/Sources/Client/Client.swift b/API/Sources/Client/Client.swift index 2d6d9ba..c0d37e0 100644 --- a/API/Sources/Client/Client.swift +++ b/API/Sources/Client/Client.swift @@ -1,5 +1,5 @@ -import ApolloAPI import Apollo +import ApolloAPI import Foundation public typealias TokenFactory = () async throws -> String? @@ -22,7 +22,7 @@ public extension Client { } } } - + func getAsync(query: Q, cachePolicy: Apollo.CachePolicy = .fetchIgnoringCacheCompletely) async -> Q.Data? { return await withCheckedContinuation { c in self.apollo.fetch(query: query, cachePolicy: cachePolicy) { result in @@ -41,20 +41,21 @@ public extension Client { } } } - - func perform(mutation: M) { + + func perform(mutation: M) { apollo.perform(mutation: mutation) } - + func clearCache(callbackQueue: DispatchQueue = .main, callback: @escaping () -> Void) { - apollo.clearCache() { _ in + apollo.clearCache { _ in callback() } } } + public struct Client { internal var apollo: ApolloClient - + internal init(apollo: ApolloClient) { self.apollo = apollo } @@ -71,9 +72,8 @@ public func NewClient(apiUrl: String, tokenFactory: @escaping TokenFactory) -> C let url = URL(string: apiUrl)! let requestChainTransport = RequestChainNetworkTransport(interceptorProvider: provider, - endpointURL: url) + endpointURL: url) return Client(apollo: ApolloClient(networkTransport: requestChainTransport, store: store)) } - diff --git a/BCC Media.xcworkspace/xcshareddata/swiftpm/Package.resolved b/BCC Media.xcworkspace/xcshareddata/swiftpm/Package.resolved index 559ba0e..5409ef5 100644 --- a/BCC Media.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/BCC Media.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apollographql/apollo-ios.git", "state" : { - "revision" : "ff54632b8740ecfb858bae4630d822e615c7ef1c", - "version" : "1.8.0" + "revision" : "eedde2151859011a44bb7cb05388deb2bf532644", + "version" : "1.9.3" } }, {