Serverless — REST, GraphQL, and AppSync
Develop serverless APIs using REST, GraphQL, and AWS AppSync.
We developed a serverless backend service to download the stock countries and stocks. The data is stored in the DynamoDB tables. For applications to access the data, normally we will use APIs.
In this article, we are going to explore using REST, GraphQL, and the AWS AppSync service to access the stock information.
This article is part of the Serverless for Beginners series.
The source code can be found in this repository.
We use Serverless Stack to develop our application on AWS. In the previous article, we use the SST Cron Jobs to create a backend service to scrape stock information. Internally the cron job uses an EventBridge rule that triggers a Lambda function based on the defined schedule. We develop the Lambda function using Python as we want to use the
For the APIs, let’s use Typescript for our project. We can create a Typescript-based project using the following command.
npx create-serverless-stack@latest --language typescript --use-yarn alpha2phi
- We specify the language to be Typescript.
- We use
yarnas the package manager.
- The project is called
A screenshot of the project layout is shown below.
Our final project layout will look like the below screenshot.
Let’s start to develop REST APIs to access the DynamoDB tables.
stacks/ApiStacks.ts file with the following code.