Rewriting note-service using CDK, TypeScript, and GraphQL. It's a CRUD app for storing notes.
- Sign up for an AWS account.
- Follow the instructions to install and configure the AWS CLI on your computer.
- Bootstrap your AWS account ("environment") with the CDK.
- Install NodeJS on your computer. We recommend the version specified in the
.nvmrcfile in the root of this project.
- Clone this repo and run
npm installfrom the project root. - From the project root run
npm run deploy. This will build and deploy this application using thecdkto your bootstrapped AWS account/region. Note: the first time running this command might result in an error...if that happens runnpm run buildfirst. 2a. If using a non-default AWS profile, you cannpm run buildto build the TypeScript and then runnpm run cdk deploy -- --profile <your-profile-name-here> - Get the
apiIdandapiURLfrom the output in your console. You will need these values later to make requets to the API. - Send requests to the application using a third party client or login to the AWS AppSync console and make requests from
Queries. I personally like to use Postman, but here's some other suggestions if you don't have a preferred way to send requests to an API.
Currently this application is using the API key authorization setting. You can obtain the API key by logging into the AWS AppSync console after a successful deploy. Alternatively, you can run this command using the AWS CLI and the apiId that printed out to your console after a successfuly deploy to obtain your key:
aws appsync list-api-keys --api-id <api id here>
The key is good for 30 days after deploy. After that you'll need to generate a new one.
If you're using Postman or making API calls through a client make sure to set a header x-api-key to the value of your API key.
- List notes
query ListNotes {
listNotes {
items {
author
content
createdAt
updatedAt
id
}
total
}
}
- Get note by id
query GetNote($id: ID = "Note id goes here") {
getNote(id: $id) {
author
content
createdAt
id
updatedAt
}
}
- Create note
mutation CreateNote($author: String = "Author goes here", $content: String = "Content goes here") {
createNote(note: {author: $author, content: $content}) {
author
content
createdAt
id
updatedAt
}
}
- Delete note
mutation DeleteNote($id: ID = "ID to delete goes here") {
deleteNote(id: $id)
}
- Update note
mutation UpdateNote($content: String = "add note content here") {
updateNote(content: $content, id: "add note id here") {
updatedAt
id
createdAt
content
author
}
}
To remote the CloudFormation stack and created resources run npm run destroy and confirm on the command line from the project root.
npm run buildcompile typescript to jsnpm run watchwatch for changes and compilenpm run deployrun typescript compiler then deploy to your default AWS account/region via the cdknpm installinstalls all dependencies including thepostinstallscriptnpm run testperform the jest unit testsnpm run cdk diffcompare deployed stack with current statenpm run cdk synthemits the synthesized CloudFormation template
The cdk.json file tells the CDK Toolkit how to execute the app.
See CONTRIBUTING.md for more info on our guildelines.