0.9.2 • Published 4 years ago

@graphity/server-lambda v0.9.2

Weekly downloads
42
License
MIT
Repository
github
Last release
4 years ago

Graphity - Server Lambda

Installation

npm install @graphity/server-lambda --save
import { APIGatewayProxyHandler } from 'aws-lambda'

import { Graphity } from 'graphity'
import { ServerLambda } from '@graphity/server-lambda'

const graphity = new Graphity({
  resolvers: [
    HomeResolver,
    /* ... */
  ],
})

graphity.register(new AuthProvider())
graphity.register(new AwsProvider())
graphity.register(new TypeormProvider())

const server = new ServerLambda(graphity) // without boot

export const handler: APIGatewayProxyHandler = (event, ctx, callback) => server.execute(event, ctx, callback)

Options

interface ServerLambdaOptions {
  callbackWaitsForEmptyEventLoop?: boolean
  cors?: {
    origin?: boolean | string | string[],
    methods?: string | string[],
    allowedHeaders?: string | string[],
    exposedHeaders?: string | string[],
    credentials?: boolean,
    maxAge?: number,
  }
}

CORS

To use CORS, simply set the following options.

const server = new ServerLambda(graphity, {
  cors: {
    origin: '*',
    credentials: true,
  },
})

callbackWaitsForEmptyEventLoop

When using a persistent connection such as a database, there may be no response. In this case, you can do the following:

const server = new ServerLambda(graphity, {
  callbackWaitsForEmptyEventLoop: false,
})

For more information, see AWS Lambda Context Object in Node.js.

0.9.2

4 years ago

0.9.1

4 years ago

0.9.0

4 years ago

0.8.0

4 years ago

0.8.0-alpha.13

4 years ago

0.8.0-alpha.12

4 years ago

0.8.0-alpha.11

4 years ago

0.8.0-alpha.10

4 years ago

0.8.0-alpha.9

4 years ago

0.8.0-alpha.8

4 years ago

0.8.0-alpha.7

4 years ago

0.8.0-alpha.5

4 years ago

0.8.0-alpha.4

4 years ago

0.8.0-alpha.3

5 years ago

0.8.0-alpha.2

5 years ago

0.8.0-alpha.1

5 years ago

0.8.0-alpha.0

5 years ago

0.7.0

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago