1.2.2 • Published 1 year ago

@rick.giles/apollo-server-integrations-aws-lambda v1.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@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);
1.2.2

1 year ago

1.2.1

1 year ago