I’m using Apollo version 1.11.0 using swift package manager.
I’m on Xcode 15.3 on an M3 Apple Silicon machine. The version on the demo code is 1.2. I tried to change to that but is still didn’t. If I change the version on the demo project it fails with similar messages. I’ve tried other variants of code. Interestingly if I let Xcode add the stubs it still says it doesn’t conform. The second error is weird too because if I try to add ‘any Error’ in the closure Xcode treats that as error. Anyone encountered similar issues? I’m sure if the problem is with Xcode or Apollo.
Here is my class.
import Apollo
import ApolloAPI
class AuthorizationInterceptor: ApolloInterceptor {
func interceptAsync<Operation>(
chain: RequestChain,
request: HTTPRequest<Operation>,
response: HTTPResponse<Operation>?,
completion: @escaping (Result<GraphQLResult<Operation.Data>, Error>) -> Void
) where Operation : GraphQLOperation {
let keychain = KeychainSwift()
if let token = keychain.get(LoginView.loginKeychainKey) {
request.addHeader(name: "Authorization", value: token)
}
chain.proceedAsync(request: request,
response: response,
completion: completion)
}
}```
Hi @TimK - I think this is just that the demo project hasn’t been updated as the function definitions have changed. I’ll get that updated and get back to you here.
Thanks Calvin. The demo project now works with higher versions but when I insert the interceptor code in to my own project I get the same errors. I’m now testing against Apollo 1.7. 0. I can also get the code to work in a test project with the same dependencies. It think it must be something in my build settings.
Found the problem. There was a redeclaration (rather than extension) of Error in my code which was causing this to fail. Thanks again for updating the code @calvincestari . It did help unravel this issue.
Hi @TimK - would you mind filling out a 1-minute survey to help us understand more about your experience with Apollo iOS? What do you like best? What needs to be improved? Your honest feedback will help us make the best library possible, thank you.