v2
Integrations
AWS Lambda
⚠️
This is the documentation for the old GraphQL Yoga version 2. We recommend upgrading to the latest GraphQL Yoga version 5.

Migrate to GraphQL Yoga v5

Integration with AWS Lambda

AWS Lambda is a serverless computing platform that makes it easy to build applications that run on the AWS cloud. GraphQL Yoga is platform-agnostic so they can fit together easily. To reduce the boilerplate we prefer to use Serverless Express from Vendia.

Installation

Terminal
yarn add @vendia/serverless-express @graphql-yoga/node graphql

Example

graphql.ts
import type { Handler } from '@aws-cdk/aws-lambda'
import { createServer } from '@graphql-yoga/node'
import { configure } from '@vendia/serverless-express'
 
const app = createServer()
 
export const handler: Handler = configure({
  // Pass Yoga as app
  app,
  // Pass Yoga's logger to listen to the logs from Serverless Express as well
  log: app.logger
})
💡

You can also check a full example on our GitHub repository here.