Skip to content

Commit

Permalink
fix: apollo dependency issue
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasgangso committed Apr 5, 2024
1 parent b87ced1 commit 1f8a4d9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions API/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 9 additions & 9 deletions API/Sources/Client/Client.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ApolloAPI
import Apollo
import ApolloAPI
import Foundation

public typealias TokenFactory = () async throws -> String?
Expand All @@ -22,7 +22,7 @@ public extension Client {
}
}
}

func getAsync<Q: GraphQLQuery>(query: Q, cachePolicy: Apollo.CachePolicy = .fetchIgnoringCacheCompletely) async -> Q.Data? {
return await withCheckedContinuation { c in
self.apollo.fetch(query: query, cachePolicy: cachePolicy) { result in
Expand All @@ -41,20 +41,21 @@ public extension Client {
}
}
}
func perform<M : GraphQLMutation>(mutation: M) {

func perform<M: GraphQLMutation>(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
}
Expand All @@ -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))
}

4 changes: 2 additions & 2 deletions BCC Media.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down

0 comments on commit 1f8a4d9

Please sign in to comment.