Gathering detailed insights and metrics for @hydre/graphql-lambda-ws
Gathering detailed insights and metrics for @hydre/graphql-lambda-ws
Gathering detailed insights and metrics for @hydre/graphql-lambda-ws
Gathering detailed insights and metrics for @hydre/graphql-lambda-ws
npm install @hydre/graphql-lambda-ws
Typescript
Module System
Node Version
NPM Version
Total Downloads
3,150
Last Day
1
Last Week
5
Last Month
29
Last Year
569
Minified
Minified + Gzipped
Latest Version
2.3.7
Package Id
@hydre/graphql-lambda-ws@2.3.7
Unpacked Size
10.26 kB
Size
3.97 kB
File Count
7
NPM Version
9.6.6
Node Version
20.0.0
Published on
Jun 14, 2023
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
150%
5
Compared to previous week
Last Month
-68.5%
29
Compared to previous month
Last Year
-78%
569
Compared to previous year
Welcome to GraphQL Serverless WebSocket library, a simple and powerful solution for implementing GraphQL subscriptions over WebSocket on Serverless architectures. 🛰️🌟
Use the package manager npm to install GraphQL Serverless WebSocket Library.
1npm install @hydre/graphql-lambda-ws
This library exposes a single function that returns a new server instance. This function takes an options object with the following properties:
The returned server instance is a function that you can use as your AWS Lambda handler.
Here is a simple usage example:
1import serve from '@hydre/graphql-lambda-ws' 2import make_schema from '@hydre/make_schema' 3 4export const connect = (_, __, cb) => cb(null, { statusCode: 200, body: '🇺🇦' }) 5 6// this returns a function (event, context) => {} 7export default serve({ 8 // the build schema 9 schema: make_schema({ ... }), 10 // An async function that builds the context for each request. 11 // `set_headers` can be called to assign headers to the response 12 build_context: async ({ event, context, set_headers }) => ({}), 13 // The root value for your resolvers 14 root_value: {}, 15 // Options for the AWS API Gateway Management API client. @see https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-apigatewaymanagementapi/ 16 aws_client_options: { endpoint: 'http://localhost:3001' }, 17 // A function that formats errors before they're returned to the client. 18 format_error: error => error, 19 // log every lambda responses 20 log_response: false 21})
You may use it along Serverless like this
1service: my-service 2frameworkVersion: '3' 3useDotenv: true 4 5provider: 6 name: aws 7 runtime: nodejs18.x 8 9functions: 10 connect: 11 handler: src/index.connect 12 events: 13 - websocket: 14 route: $connect 15 default: 16 handler: src/index.default 17 events: 18 - websocket: 19 route: $default 20 21plugins: 22 - serverless-dotenv-plugin 23 - serverless-offline
Now run
1sls offline
Try it in your terminal with wscat
1wscat -c ws://localhost:3001 2> {"query":"subscription { test }"}
Find a vuejs example under /example/index.js
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to test your changes
No vulnerabilities found.
No security vulnerabilities found.