@lamware/apollo
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published
NPM Discord Apache-2.0

Lamware - Apollo Server

This Lamware Middleware utilizes the official apollo-server-lambda package to set-up your Apollo Server outside of the main handler, improving performance.

Installation

This package is available via NPM:

yarn add @lamware/apollo

# or

npm install @lamware/apollo

Usage

import type { APIGatewayProxyHandlerV2 } from 'aws-lambda';
import { ApolloServer } from 'apollo-server-lambda';
import { apollo } from '@lamware/apollo';
import { lamware } from '@lamware/core';

const { handler } = lamware<APIGatewayProxyHandlerV2<any>>()
  // You can pass regular Apollo options.
  .use(apollo({
    introspection: false,
    debug: false,
    schema: ...,
  }))
  // You can also pass an entire Apollo Server instance.
  .use(apollo(new ApolloServer({
    introspection: false,
    debug: false,
    schema: ...,
  })))
  // Or even an (a)synchronous closure!
  .use(apollo(async () => {
    return new ApolloServer({
      introspection: false,
      debug: false,
      schema: ...,
    });
  }))
  .execute(async (payload) => {
    return payload.state.apolloHandler(payload);
  });

export { handler };

Package Sidebar

Install

npm i @lamware/apollo

Weekly Downloads

1

Version

2.0.1

License

GPL-3.0-only

Unpacked Size

1.69 MB

Total Files

43

Last publish

Collaborators

  • oyed