A demonstration of how to use SST to build and deploy a GraphQL endpoint with backing services written in Go.
This project was bootstrapped with Create Serverless Stack.
Start by installing the dependencies.
$ yarn install
A sample application demonstrating how to build different services deployed as Lambda functions.
Here we build and deploy 4 Lambda functions:
- One Lambda function with the NodeJS runtime for Apollo Server (Apollo Stack)
- One Lambda function with the Go runtime for user services (Users API Stack)
- One Lambda function with the Go runtime for user tasks (User Tasks Stack)
- One Lambda function with the Go runtime as a test route (API Stack)
Though the API Gateways fronting Apollo Server and API stacks are accessible individually, here we are demonstrating using the RESTful API stack as a datasource for the Apollo Server.
The routes exposed by the API Stack are protected with a Cognito Pool (created within the stack) and require a valid JWT token. The GraphQL route is open to the public but passes the authorization header to the API endpoints.
To demonstrate connection to a DynamoDB table from the RESTful services, a DynamoDB table is created and accessible by the API stack.
Example Request Path:
User->API Gateway->Apollo Stack->API Gateway->API Stack
Starts the local Lambda development environment.
Build your app and synthesize your stacks.
Generates a .build/
directory with the compiled files and a .build/cdk.out/
directory with the
synthesized CloudFormation stacks.
Deploy all your stacks to AWS. Or optionally deploy a specific stack.
Remove all your stacks and all of their resources from AWS. Or optionally remove a specific stack.
Runs your tests using Jest. Takes all the Jest CLI options.
Use the following commands to create, verify, and authenticate a user in Cognito
# Create and verify a user in Cognito
make create-user CLIENT_ID=$CLIENT_ID USER_POOL_ID=$USER_POOL_ID EMAIL=$EMAIL PASSWORD=$PASSWORD
# Authenticate a user and get the required token
make user-token CLIENT_ID=$CLIENT_ID EMAIL=$EMAIL PASSWORD=$PASSWORD
Learn more about the Serverless Stack.