Skip to content

Commit

Permalink
docs: Fix tutorial code for 1.3 migration (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
calvincestari authored and gh-action-runner committed Nov 6, 2023
1 parent 67685de commit f1caf14
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions docs/source/tutorial/tutorial-authenticate-operations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import Apollo
import ApolloAPI

class AuthorizationInterceptor: ApolloInterceptor {
public var id: String = UUID().uuidString

func interceptAsync<Operation>(
chain: RequestChain,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
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.

0 comments on commit f1caf14

Please sign in to comment.