Serverless — REST, GraphQL, and AppSync

Develop serverless APIs using REST, GraphQL, and AWS AppSync.

alpha2phi
7 min readMar 22, 2022

--

Serverless — REST, GraphQL, and 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.

Getting Started

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 investpy library.

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 yarn as the package manager.
  • The project is called alpha2phi.

A screenshot of the project layout is shown below.

Project Layout

Our final project layout will look like the below screenshot.

Final Project Layout

REST

Let’s start to develop REST APIs to access the DynamoDB tables.

API Stack

Create the stacks/ApiStacks.ts file with the following code.

--

--

alpha2phi

Software engineer, Data Science and ML practitioner.

Recommended from Medium

Lists

See more recommendations