From c588a3298d28ce07072c94ac40ba77378701d7c5 Mon Sep 17 00:00:00 2001 From: Calvin Cestari Date: Fri, 3 Nov 2023 09:55:51 -0700 Subject: [PATCH] docs: Fix tutorial code for 1.3 migration --- .../tutorial/tutorial-authenticate-operations.mdx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/source/tutorial/tutorial-authenticate-operations.mdx b/docs/source/tutorial/tutorial-authenticate-operations.mdx index fc8e38ee0..f24d080d1 100644 --- a/docs/source/tutorial/tutorial-authenticate-operations.mdx +++ b/docs/source/tutorial/tutorial-authenticate-operations.mdx @@ -24,6 +24,7 @@ import Apollo import ApolloAPI class AuthorizationInterceptor: ApolloInterceptor { + public var id: String = UUID().uuidString func interceptAsync( chain: RequestChain, @@ -51,9 +52,11 @@ if let token = keychain.get(LoginView.loginKeychainKey) { request.addHeader(name: "Authorization", value: token) } -chain.proceedAsync(request: request, - response: response, - completion: completion) +chain.proceedAsync( + request: request, + response: response, + interceptor: self, + completion: completion) ``` An array of `ApolloInterceptor`s which are handed off to each request to perform in order is set up by an object conforming to the `InterceptorProvider` protocol. There's a `DefaultInterceptorProvider` which has an array with most of the Interceptors you'd want to use. @@ -112,4 +115,4 @@ let keychain = KeychainSwift() Build and run the application. Whenever a network request goes out, that breakpoint should now get hit. If you're logged in, your token will be sent to the server whenever you make a request! -Now that your operations are being authenticated, it's time to [define additional mutations](tutorial-define-additional-mutations) to be able to book and cancel trips. \ No newline at end of file +Now that your operations are being authenticated, it's time to [define additional mutations](tutorial-define-additional-mutations) to be able to book and cancel trips.