0.9.2 • Published 3 years ago
@graphity/server-lambda v0.9.2
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
3 years ago
0.9.1
3 years ago
0.9.0
3 years ago
0.8.0
3 years ago
0.8.0-alpha.13
3 years ago
0.8.0-alpha.12
3 years ago
0.8.0-alpha.11
3 years ago
0.8.0-alpha.10
3 years ago
0.8.0-alpha.9
3 years ago
0.8.0-alpha.8
3 years ago
0.8.0-alpha.7
3 years ago
0.8.0-alpha.5
3 years ago
0.8.0-alpha.4
3 years ago
0.8.0-alpha.3
3 years ago
0.8.0-alpha.2
3 years ago
0.8.0-alpha.1
3 years ago
0.8.0-alpha.0
3 years ago
0.7.0
4 years ago
0.6.3
4 years ago
0.6.2
4 years ago
0.6.1
4 years ago
0.6.0
4 years ago