websockets-graphql-serverless

所属分类:Websocket编程
开发工具:TypeScript
文件大小:0KB
下载次数:0
上传日期:2022-06-26 07:30:30
上 传 者sh-1993
说明:  websockets graphql无服务器,,
(websockets-graphql-serverless,,)

文件列表:
.eslintrc.json (43, 2020-12-13)
Makefile (97, 2020-12-13)
codegen.yml (120, 2020-12-13)
package.json (1319, 2020-12-13)
resources/ (0, 2020-12-13)
resources/dynamodb.yml (597, 2020-12-13)
serverless.yml (1950, 2020-12-13)
src/ (0, 2020-12-13)
src/common/ (0, 2020-12-13)
src/common/apiGateway.ts (515, 2020-12-13)
src/common/combineQueriesAndMutations.ts (523, 2020-12-13)
src/common/dateFunctions.ts (130, 2020-12-13)
src/common/dynamo.ts (1079, 2020-12-13)
src/common/dynamoHelpers.ts (36, 2020-12-13)
src/common/generateTypesFromObject.ts (1619, 2020-12-13)
src/common/getEnvironmentVariables.ts (415, 2020-12-13)
src/common/responseWrappers.ts (1729, 2020-12-13)
src/common/writeGraphQLSchema.ts (312, 2020-12-13)
src/entities/ (0, 2020-12-13)
src/entities/activities/ (0, 2020-12-13)
src/entities/activities/graphql.ts (1745, 2020-12-13)
src/entities/activities/model.ts (1632, 2020-12-13)
src/entities/connections/ (0, 2020-12-13)
src/entities/connections/model.ts (1914, 2020-12-13)
src/entities/subscriptions/ (0, 2020-12-13)
src/entities/subscriptions/model.ts (1377, 2020-12-13)
src/generated/ (0, 2020-12-13)
src/generated/schema.graphql (418, 2020-12-13)
src/generated/schemaTypes.ts (1299, 2020-12-13)
src/handlers/ (0, 2020-12-13)
src/handlers/activityStreamHandler.ts (1557, 2020-12-13)
src/handlers/connectionHandler.ts (383, 2020-12-13)
src/handlers/graphqlHandler.ts (2079, 2020-12-13)
src/types/ (0, 2020-12-13)
src/types/graphQLTypes.ts (966, 2020-12-13)
tsconfig.json (466, 2020-12-13)

# Serverless GraphQL Subscriptions & WebSockets AWS APIGateway provides a cheap, scalable way to do websockets out of the box. Your webclients can create connections to API Gateway directly and not maintain long-lived connections directly with a server. This let's you do really flexible things behind the scenes when it comes to using streams and events to publish to websocket channels. This repository is an example setup showing how Serverless, GraphQL (without Apollo Server), and DynamoDB can be added to any existing Serverless GraphQL setup. ## Architecture 1. Connection Handler The connection handler is responsible for allowing websockets to connect and disconnect from API Gateway. It also stores the connectionIds in DynamoDB for use later 2. GraphQL Handler This is a full-GraphQL endpoint. You could put an entire api for a business in here. The subscription GraphQL actions that are exposed through this API are only responsible for storing in DynamoDB the request of a connection to be notified about a certain event. These subscriptions **do not** actually send the messages via websockets. 3. Stream Handler The final handler is a DynamoDB stream handler. This handler examines items to see if there are any subscriptions that need to be notified about the change. It then calls API Gateway directly via (ApiGatewayManagementApi().postToConnection()) and let's API Gateway send the message to any client that is still maintaining a websocket connection. ## Flexibility Since you could basically swap out DynamoDB in this example for your main datastore, you could essentially catch events from anywhere (EventBridge, SQS, SNS), format them, and then publish them to APIGateway. This completely decouples the subscribing to events via GraphQL from the publishing of change events. ## Deploying 1. Clone the repo 2. yarn 3. ./node_modules/serverless/bin/serverless.js deploy --stage prod You will see your websocket and http addresses printed to the console after you deploy.

近期下载者

相关文件


收藏者