Skip to content

Commit 71867c4

Browse files
committed
revamp appsync
1 parent e151dc5 commit 71867c4

File tree

1 file changed

+35
-33
lines changed

1 file changed

+35
-33
lines changed

src/content/docs/aws/services/appsync.md

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
title: "AppSync"
3-
linkTitle: "AppSync"
43
description: Get started with AppSync on LocalStack
54
tags: ["Ultimate"]
65
---
@@ -11,7 +10,7 @@ AppSync is a managed service provided by Amazon Web Services (AWS) that enables
1110
AppSync allows you to define your data models and business logic using a declarative approach, and connect to various data sources, including other AWS services, relational databases, and custom data sources.
1211

1312
LocalStack allows you to use the AppSync APIs in your local environment to connect your applications and services to data and events.
14-
The supported APIs are available on our [API coverage page]({{< ref "coverage_appsync" >}}), which provides information on the extent of AppSync's integration with LocalStack.
13+
The supported APIs are available on our [API coverage page](), which provides information on the extent of AppSync's integration with LocalStack.
1514

1615
## Getting started
1716

@@ -25,20 +24,20 @@ We will demonstrate how to create an AppSync API with a DynamoDB data source usi
2524
You can create a DynamoDB table using the [`CreateTable`](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_CreateTable.html) API.
2625
Execute the following command to create a table named `DynamoDBNotesTable` with a primary key named `NoteId`:
2726

28-
{{< command >}}
29-
$ awslocal dynamodb create-table \
27+
```bash
28+
awslocal dynamodb create-table \
3029
--table-name DynamoDBNotesTable \
3130
--attribute-definitions AttributeName=NoteId,AttributeType=S \
3231
--key-schema AttributeName=NoteId,KeyType=HASH \
3332
--billing-mode PAY_PER_REQUEST
34-
{{< /command >}}
33+
```
3534

3635
After the table is created, you can use the [`ListTables`](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ListTables.html) API.
3736
Run the following command to list all tables in your running LocalStack container:
3837

39-
{{< command >}}
40-
$ awslocal dynamodb list-tables
41-
{{< /command >}}
38+
```bash
39+
awslocal dynamodb list-tables
40+
```
4241

4342
The following output would be retrieved:
4443

@@ -55,11 +54,11 @@ The following output would be retrieved:
5554
You can create a GraphQL API using the [`CreateGraphqlApi`](https://docs.aws.amazon.com/appsync/latest/APIReference/API_CreateGraphqlApi.html) API.
5655
Execute the following command to create a GraphQL API named `NotesApi`:
5756

58-
{{< command >}}
59-
$ awslocal appsync create-graphql-api \
57+
```bash
58+
awslocal appsync create-graphql-api \
6059
--name NotesApi \
6160
--authentication-type API_KEY
62-
{{< /command >}}
61+
```
6362

6463
The following output would be retrieved:
6564

@@ -83,10 +82,10 @@ The following output would be retrieved:
8382
You can now create an API key for your GraphQL API using the [`CreateApiKey`](https://docs.aws.amazon.com/appsync/latest/APIReference/API_CreateApiKey.html) API.
8483
Execute the following command to create an API key for your GraphQL API:
8584

86-
{{< command >}}
87-
$ awslocal appsync create-api-key \
85+
```bash
86+
awslocal appsync create-api-key \
8887
--api-id 014d18d0c2b149ee8b66f39173
89-
{{< /command >}}
88+
```
9089

9190
The following output would be retrieved:
9291

@@ -130,11 +129,11 @@ type Schema {
130129
You can start the schema creation process using the [`StartSchemaCreation`](https://docs.aws.amazon.com/appsync/latest/APIReference/API_StartSchemaCreation.html) API.
131130
Execute the following command to start the schema creation process:
132131

133-
{{< command >}}
134-
$ awslocal appsync start-schema-creation \
132+
```bash
133+
awslocal appsync start-schema-creation \
135134
--api-id 014d18d0c2b149ee8b66f39173 \
136135
--definition file://schema.graphql
137-
{{< /command >}}
136+
```
138137

139138
The following output would be retrieved:
140139

@@ -149,13 +148,13 @@ The following output would be retrieved:
149148
You can create a data source using the [`CreateDataSource`](https://docs.aws.amazon.com/appsync/latest/APIReference/API_CreateDataSource.html) API.
150149
Execute the following command to create a data source named `DynamoDBNotesTable`:
151150

152-
{{< command >}}
153-
$ awslocal appsync create-data-source \
151+
```bash
152+
awslocal appsync create-data-source \
154153
--name AppSyncDB \
155154
--api-id 014d18d0c2b149ee8b66f39173 \
156155
--type AMAZON_DYNAMODB \
157156
--dynamodb-config tableName=DynamoDBNotesTable,awsRegion=us-east-1
158-
{{< /command >}}
157+
```
159158

160159
The following output would be retrieved:
161160

@@ -179,27 +178,27 @@ You can create a resolver using the [`CreateResolver`](https://github.com/locals
179178
You can create a custom `request-mapping-template.vtl` and `response-mapping-template.vtl` file to use as a mapping template to use for requests and responses respectively.
180179
Execute the following command to create a VTL resolver attached to the `PaginatedNotes.notes` field:
181180

182-
{{< command >}}
183-
$ awslocal appsync create-resolver \
181+
```bash
182+
awslocal appsync create-resolver \
184183
--api-id 014d18d0c2b149ee8b66f39173 \
185184
--type Query \
186185
--field PaginatedNotes.notes \
187186
--data-source-name AppSyncDB \
188187
--request-mapping-template file://request-mapping-template.vtl \
189188
--response-mapping-template file://response-mapping-template.vtl
190-
{{< /command >}}
189+
```
191190

192191
## Custom GraphQL API IDs
193192

194193
You can employ a pre-defined ID during the creation of GraphQL APIs by utilizing the special tag `_custom_id_`.
195194
For example, the following command will create a GraphQL API with the ID `faceb00c`:
196195

197-
{{< command >}}
198-
$ awslocal appsync create-graphql-api \
196+
```bash
197+
awslocal appsync create-graphql-api \
199198
--name my-api \
200199
--authentication-type API_KEY \
201200
--tags _custom_id_=faceb00c
202-
{{< /command >}}
201+
```
203202

204203
The following output would be retrieved:
205204

@@ -261,7 +260,7 @@ See the AWS documentation for [`evaluate-mapping-template`](https://awscli.amazo
261260

262261
### VTL resolver templates
263262

264-
{{< command >}}
263+
```bash
265264
awslocal appsync evaluate-mapping-template \
266265
--template '$ctx.result' \
267266
--context '{"result":"ok"}'
@@ -271,30 +270,33 @@ awslocal appsync evaluate-mapping-template \
271270
"logs": []
272271
}
273272
</disable-copy>
274-
{{< / command >}}
273+
```
275274

276275
### JavaScript resolvers
277276

278-
{{< command >}}
277+
```bash
279278
awslocal appsync evaluate-code \
280279
--runtime name=APPSYNC_JS,runtimeVersion=1.0.0 \
281280
--function request \
282281
--code 'export function request(ctx) { return ctx.result; }; export function response(ctx) {};' \
283282
--context '{"result": "ok"}'
284-
<disable-copy>
283+
```
284+
285+
The following output would be retrieved:
286+
287+
```bash
285288
{
286289
"evaluationResult": "ok",
287290
"logs": []
288291
}
289-
</disable-copy>
290-
{{< / command >}}
292+
```
291293

292294
## Resource Browser
293295

294296
The LocalStack Web Application provides a Resource Browser for managing AppSync APIs, Data Sources, Schema, Query, Types, Resolvers, Functions and API keys.
295297
You can access the Resource Browser by opening the LocalStack Web Application in your browser, navigating to the **Resources** section, and then clicking on **AppSync** under the **App Integration** section.
296298

297-
<img src="appsync-resource-browser.png" alt="AppSync Resource Browser" title="AppSync Resource Browser" width="900" />
299+
![AppSync Resource Browser](/images/aws/appsync-resource-browser.png)
298300

299301
The Resource Browser allows you to perform the following actions:
300302

0 commit comments

Comments
 (0)