Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Fix tutorial code for 1.3 migration #124

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading