You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can create your Apollo client by using our provided AWS AppSync endpoint and authorizer classes.
119
125
120
-
### AppSync Authorizers
126
+
```kotlin
127
+
val endpoint =AppSyncEndpoint("<your_appsync_endpoint>")
128
+
// Continue Reading to see more authorizer examples
129
+
val authorizer =ApiKeyAuthorizer("[API_KEY]")
130
+
val apolloClient =ApolloClient.Builder()
131
+
.appSync(endpoint, authorizer)
132
+
.build()
133
+
```
134
+
</Block>
135
+
136
+
</BlockSwitcher>
137
+
138
+
### Providing AppSync Authorizers
139
+
140
+
<BlockSwitcher>
141
+
142
+
<Blockname="With Amplify">
121
143
122
144
The AWS AppSync Apollo Extensions library provides a number of Authorizer classes to match the various authorization strategies that may be in use in your schema. You should choose the appropriate Authorizer type for your authorization strategy. To read more about the strategies and their corresponding auth modes, see [Available authorization strategies](/[platform]/build-a-backend/data/customize-authz/#available-authorization-strategies).
123
145
@@ -207,20 +229,6 @@ val authorizer = IamAuthorizer {
207
229
208
230
<Blockname="Without Amplify">
209
231
210
-
You can create your Apollo client by using our provided AWS AppSync endpoint and authorizer classes.
211
-
212
-
```kotlin
213
-
val endpoint =AppSyncEndpoint("<your_appsync_endpoint>")
214
-
// Continue Reading to see more authorizer examples
215
-
val authorizer =ApiKeyAuthorizer("[API_KEY]")
216
-
217
-
val apolloClient =ApolloClient.Builder()
218
-
.appSync(endpoint, authorizer)
219
-
.build()
220
-
```
221
-
222
-
### AppSync Authorizers
223
-
224
232
AWS AppSync supports the following [authorization modes](https://docs.aws.amazon.com/appsync/latest/devguide/security-authz.html). Use the corresponding Authorizer that matches the chosen authorization type.
AWS AppSync supports the following [authorization modes](https://docs.aws.amazon.com/appsync/latest/devguide/security-authz.html):
285
293
286
-
### API_KEY
294
+
####API_KEY
287
295
288
296
```swift
289
297
importAWSAppSyncApolloExtensions
@@ -292,7 +300,7 @@ let authorizer = APIKeyAuthorizer(apiKey: "[API_KEY]")
292
300
let interceptor =AppSyncInterceptor(authorizer)
293
301
```
294
302
295
-
### AMAZON_COGNITO_USER_POOLS
303
+
####AMAZON_COGNITO_USER_POOLS
296
304
297
305
If you are using Amplify Auth, you can create a method that retrieves the Cognito access token
298
306
@@ -322,7 +330,7 @@ let authorizer = AuthTokenAuthorizer(fetchLatestAuthToken: getUserPoolAccessToke
322
330
let interceptor =AppSyncInterceptor(authorizer)
323
331
```
324
332
325
-
### AWS_IAM
333
+
####AWS_IAM
326
334
327
335
If you are using Amplify Auth, you can use the following method for AWS_IAM auth
328
336
@@ -418,11 +426,11 @@ You can alternatively download the introspection schema using the [`fetch-schema
418
426
<BlockSwitcher>
419
427
420
428
<Blockname="With Amplify">
421
-
### Amplify provided .graphql files
429
+
####Amplify provided .graphql files
422
430
1. Within your Amplify Gen2 backend, run: `npx ampx generate graphql-client-code --format graphql-codegen --statement-target graphql --out graphql`
423
431
2. Copy the generated files (`mutations.graphql`, `queries.graphql`, `subscriptions.graphql`) to your `{app}/src/main/graphql` folder as shown in the [Apollo documentation](https://www.apollographql.com/docs/kotlin#getting-started)
424
432
425
-
### Manual
433
+
####Manual
426
434
1. Navigate to the **Queries** tab in your API on the [AWS AppSync console](https://console.aws.amazon.com/appsync/home). Here, you can test queries, mutations, and subscriptions in the GraphQL playground.
427
435
2. Enter your GraphQL operation (query, mutation, or subscription) in the editor and click **Run** to execute it.
428
436
3. Observe the request and response structure in the results. This gives you insight into the exact call patterns and structure that Apollo will use.
0 commit comments