Installations
npm install aws-lambda-graphql
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=10
Node Version
14.17.6
NPM Version
lerna/3.22.1/node@v14.17.6+x64 (darwin)
Score
57
Supply Chain
87
Quality
69.3
Maintenance
50
Vulnerability
97
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (98.24%)
JavaScript (0.88%)
HTML (0.76%)
Shell (0.12%)
Developer
Download Statistics
Total Downloads
899,468
Last Day
677
Last Week
3,656
Last Month
14,502
Last Year
139,215
GitHub Statistics
462 Stars
275 Commits
90 Forks
18 Watching
20 Branches
17 Contributors
Bundle Size
0.99 MB
Minified
313.34 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.0.0-alpha.24
Package Id
aws-lambda-graphql@1.0.0-alpha.24
Unpacked Size
229.36 kB
Size
49.24 kB
File Count
136
NPM Version
lerna/3.22.1/node@v14.17.6+x64 (darwin)
Node Version
14.17.6
Total Downloads
Cumulative downloads
Total Downloads
899,468
Last day
-48.1%
677
Compared to previous day
Last week
-28.8%
3,656
Compared to previous week
Last month
82%
14,502
Compared to previous month
Last year
-48.9%
139,215
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
aws-lambda-graphql
⚠️ This documentation is currently for 1.0.0-alpha.X package which supports only subscriptions-transport-ws and drops the legacy protocol and client support! To use old version that supports legacy protocol and client see the link 0.13.0 below.
📖Documentation for aws-lambda-graphql0.13.0
Use Apollo Server Lambda with GraphQL subscriptions over WebSocket (AWS API Gateway v2).
With this library you can do:
- same things as with apollo-server-lambda by utiizing AWS API Gateway v1
- GraphQL subscriptions over WebSocket by utilizing AWS API Gateway v2 and subscriptions-transport-ws
Table of contents
Installation
1yarn add aws-lambda-graphql graphql graphql-subscriptions 2# or 3npm install aws-lamda-graphql graphql graphql-subscriptions
Usage
There is a quick start guide.
## API
Server
Creates an Apollo Lambda server.
Options
All options from Apollo Lambda Server and
- connectionManager (
IConnectionManager
,required
) - eventProcessor (
IEventProcessor
,required
) - onError (
(err: any) => void
,optional
) - use to log errors from websocket handler on unknown error - subscriptionManager (
ISubscriptionManager
,required
) - subscriptions (
optional
)onWebsocketConnect(connection: IConnection, event: APIGatewayWebSocketEvent, context: LambdaContext): Promise<boolean|object> | object | boolean
(optional
) - onWebsocketConnect is called when the Websocket connection is initialized ($connect route). Return an object to set a context to your connection object saved in the database e.g. for saving authentication details. This is especially useful to get authentication details (API GW authorizers only run in $connect route)onConnect(messagePayload: object, connection: IConnection, event: APIGatewayWebSocketEvent, context: LambdaContext): Promise<boolean|object> | object | boolean
(optional
) - onConnect is called when the GraphQL connection is initialized (connection_init message). Return an object to set a context to your connection object saved in the database e.g. for saving authentication details. NOTE: This is not the websocket $connect route, see onWebsocketConnect for the $connect route.onOperation(message: OperationRequest, params: ExecutionParams, connection: IConnection): Promise<ExecutionParams>|ExecutionParams
(optional
)onOperationComplete(connection: IConnection, operationId: string): void
(optional
)onDisconnect(connection: IConnection): void
(optional
)- waitForInitialization (
optional
) - if connection is not initialised on GraphQL operation, wait for connection to be initialised or throw prohibited connection error. IfonConnect
is specified then we wait for initialisation otherwise we don't wait. (this is usefull if you're performing authentication inonConnect
).- retryCount (
number
,optional
,default 10
) - how many times should we try to check the connection state? - timeout (
number
,optional
,default 50ms
) - how long should we wait (in milliseconds) until we try to check the connection state again?
- retryCount (
- connectionEndpoint (
string
,optional
) - if specified, the connection endpoint will be registered with this value as opposed to extracted from the event payload (as${domainName}/${stage}
)
createHttpHandler()
Creates an AWS Lambda API Gateway v1 handler. Events are handled by apollo-server-lambda
createWebSocketHandler()
Creates an AWS Lambda API Gateway v2 handler that supports GraphQL subscriptions over WebSocket.
createEventHandler()
Creates an AWS Lambda handler for events from events source (for example DynamoDBEventStore). This method internally work with IEventProcessor
.
DynamoDBEventProcessor: IEventProcessor
AWS Lambda DynamoDB stream handler. DynamoDBEventProcessor is used internally by Server.
Options (optional
)
- onError (
(err: any) => void
,optional
) - debug (
boolean, default: false
) - optional debug mode to add logs in Cloudwatch
DynamoDBConnectionManager: IConnectionManager
IConnectionManager
implementation that stores information about connections to DynamoDB table, performs communication with them, etc.
Each connection is stored as IConnection
object.
Options
- connectionsTable (
string
,optional
,default: 'Connections'
) - name of DynamoDB table used to store connections - subscriptions (
ISubscriptionManager
,required
) - subscription manager used to register subscriptions for connections. - ttl (
number
,optional
,default: 2 hours
)- optional TTL for connections set in seconds
- the value is stored as
ttl
field on the row (you are responsible for enabling TTL on given field)
- debug (
boolean,optional,default: false
) - optional debug mode to add logs in Cloudwatch
DynamoDBEventStore: IEventStore
IEventStore
implemenation that used AWS DynamoDB as storage for published events.
Options
- eventsTable (
string
,optional
,default: 'Events'
) - events DynamoDB table name - ttl (
number
,optional
,default: 2 hours
)- optional TTL for events set in seconds
- the value is stored as
ttl
field on the row (you are responsible for enabling TTL on given field)
DynamoDBSubscriptionManager: ISubscriptionManager
ISubscriptionManager
implementation that used AWS DynamoDB as storage for subscriptions.
Stores subscriptions to a subscriptions table as event: string
and subscriptionId: string
.Make sure to set up the key schema as event: HASH
and subscriptionId: RANGE
.
Stores subscription operations to a subscription operations table as subscriptionId: string
. Make sure to set up the key schema as subscriptionId: HASH
.
Options
- subscriptionsTableName (
string
,optional
,default: 'Subscriptions'
) - subscriptionOperationsTableName - (
string
,optional
,default: 'SubscriptionOperations'
) - ttl (
number
,optional
,default: 2 hours
)- optional TTL for subscriptions and subscriptionOperations set in seconds
- the value is stored as
ttl
field on the row (you are responsible for enabling TTL on given field)
- getSubscriptionNameFromEvent (
function
,optional
,default: '(event: ISubscriptionEvent) => event.event'
)- Get the subscription name from the event
- getSubscriptionNameFromConnection (
function
,optional
,default: '(name: string, connection: IConnection) => name'
)- Get the subscription name from the subscription connection
DynamoDBRangeSubscriptionManager: ISubscriptionManager
- This one allow you to subscribe to multiple events
ISubscriptionManager
implementation that used AWS DynamoDB as storage for subscriptions.
Stores subscriptions to a subscriptions table as event: string
and subscriptionId: string
.Make sure to set up the key schema as event: HASH
and subscriptionId: RANGE
.
Stores subscription operations to a subscription operations table as subscriptionId: string
. Make sure to set up the key schema as subscriptionId: HASH
and event: RANGE
.
Options
- subscriptionsTableName (
string
,optional
,default: 'Subscriptions'
) - subscriptionOperationsTableName - (
string
,optional
,default: 'SubscriptionOperations'
) - ttl (
number
,optional
,default: 2 hours
)- optional TTL for subscriptions and subscriptionOperations set in seconds
- the value is stored as
ttl
field on the row (you are responsible for enabling TTL on given field)
IConnection
- id: string - connection id
- connectionData
IConnectionData
IConnectionData
- context (
object
) - connection context data provided fromGQL_CONNECTION_INIT
oronConnect
. This data is passed to graphql resolvers' context. All values should be JSON seriablizable. - isInitialized (
boolean
) - is connection initialised? Basically if you useonConnect
then this value isfalse
until theonConnect
successfully resolves with nonfalse
value.
Context creator function
Context creator function accepts IContext
and returns an object
or Promise
that resolves to an object
.
IContext
Internal context passed to the Context creator function
.
Structure:
- event - AWS Lambda event that invoked the handler
- lambdaContext - AWS Lambda handler context
- $$internal - internal object passed by this library
- connection (
IConnection
) - current connection that invoked the execution or is associated with an operation - connectionManager (
IConnectionManager
) - operation (
OperationRequest
) - operation associated with current invokation - pubSub (
PubSub
) - PubSub instance used by event store - subscriptionManager (
ISubscriptionManager
)
- connection (
PubSub
PubSub implementation that publishes events / subscribes to events using underlying event store.
Options
- eventStore: IEventStore - event store used to publish events / subscribe to events
- serializeEventPayload (
boolean, default: true
) - Serialize event payload to JSON - debug (
boolean, default: false
) - optional debug mode to add logs in Cloudwatch
Examples
- Chat App - React app
- Chat Server
- contains AWS Lambda that handles HTTP, WebSocket and DynamoDB streams
- also includes serverless.yaml file for easy deployment
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 9/25 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 15 are checked with a SAST tool
Reason
155 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-whgm-jr23-g3j9
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-j5g3-5c8r-7qfx
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-rrc9-gqf8-8rwg
- Warn: Project is vulnerable to: GHSA-4w2v-q235-vp99
- Warn: Project is vulnerable to: GHSA-cph5-m8f7-6c5x
- Warn: Project is vulnerable to: GHSA-wf5p-g6vw-rhxx
- Warn: Project is vulnerable to: GHSA-pp7h-53gx-mx7r
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw
- Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5
- Warn: Project is vulnerable to: GHSA-257v-vj4p-3w2h
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-h452-7996-h45h
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-wm7h-9275-46v2
- Warn: Project is vulnerable to: GHSA-3wcq-x3mq-6r9p
- Warn: Project is vulnerable to: GHSA-ff7x-qrg7-qggm
- Warn: Project is vulnerable to: GHSA-r9p9-mrjm-926w
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h
- Warn: Project is vulnerable to: GHSA-6h5x-7c5m-7cr7
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-2j2x-2gpw-g8fm
- Warn: Project is vulnerable to: GHSA-74fj-2j2h-c42q
- Warn: Project is vulnerable to: GHSA-pw2r-vq6v-hr8c
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97
- Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44
- Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-pfq8-rq6v-vf5m
- Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-7r28-3m3f-r2pr
- Warn: Project is vulnerable to: GHSA-r8j5-h5cx-65gg
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-fqg8-vfv7-8fj8
- Warn: Project is vulnerable to: GHSA-pppg-cpfq-h7wr
- Warn: Project is vulnerable to: GHSA-8cf7-32gw-wr33
- Warn: Project is vulnerable to: GHSA-hjrf-2m68-5959
- Warn: Project is vulnerable to: GHSA-qwph-4952-7xr6
- Warn: Project is vulnerable to: GHSA-jg8v-48h5-wgxg
- Warn: Project is vulnerable to: GHSA-36fh-84j7-cv5h
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488
- Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-3xq5-wjfh-ppjc
- Warn: Project is vulnerable to: GHSA-r6rj-9ch6-g264
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-8hfj-j24r-96c4
- Warn: Project is vulnerable to: GHSA-wc69-rhjr-hc9g
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-w7rc-rwvf-8q5r
- Warn: Project is vulnerable to: GHSA-92xj-mqp7-vmcj
- Warn: Project is vulnerable to: GHSA-wxgw-qj99-44c2
- Warn: Project is vulnerable to: GHSA-5rrq-pxf6-6jx5
- Warn: Project is vulnerable to: GHSA-8fr3-hfg3-gpgp
- Warn: Project is vulnerable to: GHSA-gf8q-jrpm-jvxq
- Warn: Project is vulnerable to: GHSA-2r2c-g63r-vccr
- Warn: Project is vulnerable to: GHSA-cfm4-qjh2-4765
- Warn: Project is vulnerable to: GHSA-x4jg-mjrx-434g
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-px4h-xg32-q955
- Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr
- Warn: Project is vulnerable to: GHSA-3j8f-xvm3-ffx4
- Warn: Project is vulnerable to: GHSA-4p35-cfcx-8653
- Warn: Project is vulnerable to: GHSA-7f3x-x4pr-wqhj
- Warn: Project is vulnerable to: GHSA-jpp7-7chh-cf67
- Warn: Project is vulnerable to: GHSA-q6wq-5p59-983w
- Warn: Project is vulnerable to: GHSA-j9fq-vwqv-2fm2
- Warn: Project is vulnerable to: GHSA-pqw5-jmp5-px4v
- Warn: Project is vulnerable to: GHSA-6fx8-h7jm-663j
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg
- Warn: Project is vulnerable to: GHSA-566m-qj78-rww5
- Warn: Project is vulnerable to: GHSA-hwj9-h5mp-3pm3
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-g954-5hwp-pp24
- Warn: Project is vulnerable to: GHSA-h755-8qp9-cq85
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-5q6m-3h65-w53x
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-x3m3-4wpv-5vgc
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-44c6-4v22-4mhx
- Warn: Project is vulnerable to: GHSA-4x5v-gmq8-25ch
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-h9rv-jmmf-4pgx
- Warn: Project is vulnerable to: GHSA-hxcc-f52p-wc94
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-h97f-5258-5593
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-3f95-r44v-8mrg
- Warn: Project is vulnerable to: GHSA-28xr-mwxg-3qc8
- Warn: Project is vulnerable to: GHSA-9p95-fxvg-qgq2
- Warn: Project is vulnerable to: GHSA-9w5j-4mwv-2wj8
- Warn: Project is vulnerable to: GHSA-xfhh-g9f5-x4m4
- Warn: Project is vulnerable to: GHSA-qm95-pgcg-qqfq
- Warn: Project is vulnerable to: GHSA-cqmj-92xf-r6r9
- Warn: Project is vulnerable to: GHSA-c9g6-9335-x697
- Warn: Project is vulnerable to: GHSA-vx3p-948g-6vhq
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v
- Warn: Project is vulnerable to: GHSA-38fc-wpqx-33j7
- Warn: Project is vulnerable to: GHSA-3329-pjwv-fjpg
- Warn: Project is vulnerable to: GHSA-p6j9-7xhc-rhwp
- Warn: Project is vulnerable to: GHSA-89gv-h8wf-cg8r
- Warn: Project is vulnerable to: GHSA-gcv8-gh4r-25x6
- Warn: Project is vulnerable to: GHSA-gmv4-r438-p67f
- Warn: Project is vulnerable to: GHSA-8h2f-7jc4-7m3m
- Warn: Project is vulnerable to: GHSA-3vjf-82ff-p4r3
- Warn: Project is vulnerable to: GHSA-g694-m8vq-gv9h
- Warn: Project is vulnerable to: GHSA-9m6j-fcg5-2442
- Warn: Project is vulnerable to: GHSA-hh27-ffr2-f2jc
- Warn: Project is vulnerable to: GHSA-rqff-837h-mm52
- Warn: Project is vulnerable to: GHSA-8v38-pw62-9cw2
- Warn: Project is vulnerable to: GHSA-hgjh-723h-mx2j
- Warn: Project is vulnerable to: GHSA-jf5r-8hm2-f872
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-776f-qx25-q3cc
- Warn: Project is vulnerable to: GHSA-72mh-269x-7mh5
- Warn: Project is vulnerable to: GHSA-h4j5-c7cj-74xg
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Score
2.5
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to aws-lambda-graphql
apollo-server-lambda
Production-ready Node.js GraphQL server for AWS Lambda
graphql-lambda-subscriptions
Graphql-WS compatible Lambda Powered Subscriptions
aws-lambda-graphql-apollo-v3
Apollo server for AWS Lambda with WebSocket subscriptions support over API Gateway v1 + v2
aws-lambda-graphql-subscriptions