This will create an AppSync API with a single Lambda connection, lambda layer for dependencies, IAM role, and AppSync API.
Create .env file
AWS_ACCESS_KEY_ID=XXXX
AWS_SECRET_ACCESS_KEY=XXXX
$ npm run setup
$ npm run deploy all
$ npm run deploy iam
$ npm run deploy layer
$ npm run deploy lambda
$ npm run deploy appsync
-
Navigate to AWS Console
-
Search for AWS AppSync and select your API
-
Open
Queries
-
Add query and run
query getUsersById {
getUsersById(id: "1") {
name
}
}
- View result
{
"data": {
"getUsers": [
{
"name": "ryan"
},
{
"name": "tyler"
}
]
}
}
-
Confirm that you have an API Key created
-
Manually copy the GraphQL schema in from this project (
components/appsync/src/schema.graphql
) and save the schema -
Manually create a DataSource of AWS Lambda pointed at the lambda function you deployed in this stack (
components/lambda
) -
Navigate to
Schema
in the AppSync console, select the GraphQL Query ofgetUsers
, manually set the request mapping template and response mapping template copying fromcomponents/appsync/src/vtl
-
Open the queries tab and run
query getUsers {
getUsers {
name
}
}
- View result
{
"data": {
"getUsers": [
{
"name": "ryan"
},
{
"name": "tyler"
}
]
}
}