I am using Apollo Client subscriptions for my app. I follow the codes here on the documentation from Apollo https://www.apollographql.com/docs/ios/subscriptions but I keep having an error on when I subscribe to the apollo subscription
Value of type 'Apollo.Cancellable' does not conform to 'Combine.Cancellable' in assignment
Here is my code
self.subscription = ApolloNetwork.shared.apollo
.subscribe(subscription: UserBalanceSubscription()) { [weak self] result in
guard let self = self else {
return
}
switch result {
case .success(let graphQLResult):
print(graphQLResult)
case .failure(let error):
print("error: \(error)")
}
}
Here is how I declare the var subscription
private var subscription: Cancellable?
I am getting confused what causing the issue and how to fix it.
CodePudding user response:
It sounds like you have a naming collision between modules (Apollo
and Combine
) that both have a Cancellable
type defined.
You can explicitly declare that you want this Cancellable
to be the one from Apollo
by doing the following:
private var subscription: Apollo.Cancellable?