This is the AWS Lambda version of the WunderGraph Cosmo Router. Please contact us if you have any questions or production use case. Why AWS lambda? Because it's cheap and scales automatically. You only pay for what you use. No need to manage servers or containers. It also integrates well with the rest of the AWS ecosystem.
Status: Beta
Demo: https://zqadzbqwsi.execute-api.us-west-1.amazonaws.com/Prod/ (Playground)
- GraphQL Queries
- GraphQL Mutations
- Telemetry Flushing after each request
- Schema Usage Tracking after each request
- Subscription: Not implemented. Please talk to us if you need this.
- AWS CLI already configured with Administrator permission
- Docker installed
- Golang
- SAM CLI - Install the SAM CLI
First signup For Cosmo Cloud and follow the onboarding process.
Run make fetch-router-config
to fetch the latest router configuration from Cosmo Cloud. We assume that you have named your graph production
.
The file is stored in router.json
and copied to the Lambda build directory on each build.
Build the router and start the API Gateway locally:
make dev
Open http://127.0.0.1:3003/ in your browser and you should see the GraphQL Playground.
This will upload the code to AWS without performing a CloudFormation deployment. This is useful for development.
make sync
Ensure that the following environment variables are set in template.yaml:
STAGE
- The name of the stage, which API Gateway uses as the first path segment in the invoke Uniform Resource Identifier (URI) e.g.Prod
for/Prod
.GRAPH_API_TOKEN
- The API token for your graph. You can find this in the Cosmo Cloud dashboard.
For production use cases, we recommend to use AWS Secrets Manager to store the GRAPH_API_TOKEN
.
make deploy
The command will package and deploy your application with the SAM CLI to AWS. You can find your API Gateway Endpoint URL in the output values displayed after deployment.
You don't have to build the router yourself. You can download the latest release and follow the instructions below.
- Download the Lambda Router binary from the official Router Releases page.
- Create a .zip archive with the binary and the
router.json
file. You can download the latestrouter.json
withwgc router fetch
.
The .zip archive should look like this:
.
└── myFunction.zip/
├── bootstrap # Extracted from the Router release archive
└── router.json # Downloaded with `wgc router fetch`
- Deploy the .zip archive to AWS Lambda. You can use SAM CLI or the AWS console. Alternatively, you can use your IaC tool of choice.