@rick.giles/apollo-server-integrations-aws-lambda
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

@as-integrations/aws-lambda

Getting started: Lambda middleware

Apollo Server runs as a part of your Lambda handler, processing GraphQL requests. This package allows you to easily integrate Apollo Server with AWS Lambda. This integration is compatible with Lambda's API Gateway V1 (REST) and V2 (HTTP). It doesn't currently claim support for any other flavors of Lambda, though PRs are welcome!

First, install Apollo Server, graphql-js, and the Lambda handler package:

npm install @apollo/server graphql @as-integrations/aws-lambda

Then, write the following to server.mjs. (By using the .mjs extension, Node treats the file as a module, allowing us to use ESM import syntax.)

import { ApolloServer } from "@apollo/server";
import { startServerAndCreateLambdaHandler } from "@as-integrations/aws-lambda";

// The GraphQL schema
const typeDefs = `#graphql
  type Query {
    hello: String
  }
`;

// A map of functions which return data for the schema.
const resolvers = {
  Query: {
    hello: () => "world",
  },
};

// Set up Apollo Server
const server = new ApolloServer({
  typeDefs,
  resolvers,
});

export default startServerAndCreateLambdaHandler(server);

Readme

Keywords

Package Sidebar

Install

npm i @rick.giles/apollo-server-integrations-aws-lambda

Weekly Downloads

0

Version

1.2.2

License

MIT

Unpacked Size

47.9 kB

Total Files

39

Last publish

Collaborators

  • rick.giles