Registry / devops / aws-lambda-graphql

aws-lambda-graphql

JSON →
library1.0.0-alpha.24jsnpmunverified

Apollo Server for AWS Lambda with WebSocket subscriptions support over API Gateway v1 + v2, by Michal Kvasničák. Version 1.0.0-alpha.24 (released 2021) supports only subscriptions-transport-ws protocol, dropping legacy client support. Requires AWS SDK v2, GraphQL 14 or 15, graphql-subscriptions, and ioredis for subscription management. Ships TypeScript types, but the 1.x alpha has breaking changes from 0.13.x. Useful for Serverless GraphQL with real-time subscriptions using API Gateway WebSockets.

npm install aws-lambda-graphql
INSTALL
IMPORT
SIG · AWS-LAMBDA-GRAPHQL
A
aws-lambda-graphql
devopsjavascriptv1.0.0-alpha.24
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Server
import { Server } from 'aws-lambda-graphql'
const { Server } = require('aws-lambda-graphql')
Since v1.0.0-alpha, package is ESM-only. Use import statement.
SubscriptionManager
import { SubscriptionManager } from 'aws-lambda-graphql'
const SubscriptionManager = require('aws-lambda-graphql').SubscriptionManager
Named import for subscription manager. Must be instantiated with Redis connection.
default (The library as a whole)
import awsLambdaGraphql from 'aws-lambda-graphql'
const awsLambdaGraphql = require('aws-lambda-graphql')
Default export exists but is discouraged; prefer named exports.

Creates an Apollo Server Lambda with WebSocket subscriptions, DynamoDB connection and event processors, Redis pub/sub.

import { Server, SubscriptionManager, DynamoDBConnectionManager, DynamoDBEventProcessor } from 'aws-lambda-graphql'; import Redis from 'ioredis'; import { ApolloServer } from 'apollo-server-lambda'; const typeDefs = ` type Query { ping: String } type Subscription { messageSent: String } `; const resolvers = { Query: { ping: () => 'pong' }, Subscription: { messageSent: { subscribe: (_, __, { pubsub }) => pubsub.asyncIterator(['MESSAGE_SENT']) } } }; const redis = new Redis(process.env.REDIS_URL ?? ''); const subscriptionManager = new SubscriptionManager({ redis }); const connectionManager = new DynamoDBConnectionManager({ tableName: 'Connections' }); const eventProcessor = new DynamoDBEventProcessor({ tableName: 'Events' }); const server = new Server({ server: new ApolloServer({ typeDefs, resolvers }), connectionManager, eventProcessor, subscriptionManager, subscriptions: { onConnect: async (messagePayload, connection, event, context) => { return { user: { id: '123' } }; } } }); export const handler = server.createHandler();
Debug
Known issues
breakingv1.0.0-alpha drops support for legacy WebSocket protocol (graphql-ws) and only supports subscriptions-transport-ws.
fix
Update clients to use subscriptions-transport-ws (e.g., Apollo-Client v2 or v3 with WebSocket link).
affects: >=1.0.0-alpha
breakingv1.0.0-alpha requires ESM imports; CommonJS require() no longer works.
fix
Switch to import syntax and ensure your Lambda runtime supports ESM or use a bundler.
affects: >=1.0.0-alpha
breakingv1.0.0-alpha requires Node.js >=10; older Node versions incompatible.
fix
Upgrade Node.js runtime in Lambda to >=10.x.
affects: >=1.0.0-alpha
deprecatedThe 'subscriptions-transport-ws' library is deprecated in favor of graphql-ws.
fix
Consider migrating to graphql-ws protocol; check future versions of this package.
affects: >=1.0.0-alpha
gotchaMust provide DynamoDB tables for connection management and event processing; default configuration may not work without them.
fix
Create DynamoDB tables with appropriate partition keys and TTL. See docs for schema.
affects: >=0.10.0
Errors
Common errors & fixes
Cannot find module 'aws-lambda-graphql'
Package not installed or wrong import path.
fix
Run 'npm install aws-lambda-graphql graphql graphql-subscriptions ioredis aws-sdk' or install missing peer dependencies.
Error: Cannot use GraphQLSchema "[object Object]" from another module or realm.
Multiple copies of 'graphql' module due to mismatched versions or dependency resolution.
fix
Ensure only one version of graphql in node_modules. Use npm dedupe or yarn resolutions.
TypeError: Class extends value undefined is not a constructor or null
Missing peer dependency 'graphql-subscriptions' or incompatible version.
fix
Install graphql-subscriptions@^1.0.0 and ensure no duplicate versions.
Connection timeout when initializing WebSocket
API Gateway WebSocket route not configured or Lambda function not connected.
fix
Configure $connect, $disconnect, and $default routes in API Gateway to invoke your Lambda. Check IAM permissions.
Upgrade
Version history
1.0.0-alpha.24latest on npm
Audit
Dependencies
aws-sdkrequiredRequired for AWS Lambda and API Gateway interaction
graphqlrequiredPeer dependency for GraphQL schema and execution
graphql-subscriptionsrequiredFor implementing GraphQL subscriptions
ioredisrequiredRequired for subscription state management and pub/sub
Agent activity
11 hits · last 30 days
node
8
Amazon
1
OpenAI (training)
1
Resources
aws-lambda-graphql — npm install aws-lambda-graphql · libregistry