All Projects → ioxe → graphql-aws-iot-server

ioxe / graphql-aws-iot-server

Licence: MIT license
Serverless server for graphql queries, mutations and subscriptions using aws iot https://www.npmjs.com/package/graphql-aws-iot-server

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to graphql-aws-iot-server

Mercure Bundle
The MercureBundle allows to easily push updates to web browsers and other HTTP clients in the Symfony full-stack framework, using the Mercure protocol.
Stars: ✭ 195 (+400%)
Mutual labels:  subscriptions
pinax-stripe-light
a payments Django app for Stripe
Stars: ✭ 670 (+1617.95%)
Mutual labels:  subscriptions
Google-IAP
Android Library for easing Google Play Billing to your apps with support for Subscriptions, In-App Purchases and Consumables with a beautiful sample app.
Stars: ✭ 129 (+230.77%)
Mutual labels:  subscriptions
Qonversion Ios Sdk
iOS SDK for cross-platform in-app purchase and subscription infrastructure, revenue analytics, engagement automation, and integrations
Stars: ✭ 206 (+428.21%)
Mutual labels:  subscriptions
react-native-todo
React Native todo list using GraphQL
Stars: ✭ 26 (-33.33%)
Mutual labels:  subscriptions
RxBilling
Rx wrapper for Billing Library with connection management
Stars: ✭ 79 (+102.56%)
Mutual labels:  subscriptions
Auto Youtube Subscription Playlist 2
Script automatically adds videos to playlists from Youtube channels and/or subscriptions (Youtube Collections alternative).
Stars: ✭ 136 (+248.72%)
Mutual labels:  subscriptions
hypersubs
an upgraded version of Meteor subscribe, which helps optimize data and performance!
Stars: ✭ 13 (-66.67%)
Mutual labels:  subscriptions
serverless-graphql-subscriptions
Graphql subscriptions with apollo-server-lambda
Stars: ✭ 67 (+71.79%)
Mutual labels:  subscriptions
cashier-paystack
Cashier provides an expressive, fluent interface to Paystack's subscription billing services.
Stars: ✭ 44 (+12.82%)
Mutual labels:  subscriptions
Mercure
Server-sent live updates: protocol and reference implementation
Stars: ✭ 2,608 (+6587.18%)
Mutual labels:  subscriptions
killbill-stripe-plugin
Kill Bill plugin for Stripe
Stars: ✭ 16 (-58.97%)
Mutual labels:  subscriptions
boutique
Immutable data storage
Stars: ✭ 44 (+12.82%)
Mutual labels:  subscriptions
Killbill
Open-Source Subscription Billing & Payments Platform
Stars: ✭ 2,396 (+6043.59%)
Mutual labels:  subscriptions
development
An Enterprise-ready Cloud Services Management Software
Stars: ✭ 38 (-2.56%)
Mutual labels:  subscriptions
Youtubeshop
Youtube autolike and autosubs script
Stars: ✭ 177 (+353.85%)
Mutual labels:  subscriptions
kbcli
GO client library for Kill Bill
Stars: ✭ 22 (-43.59%)
Mutual labels:  subscriptions
netlify-stripe-subscriptions
An example of managing subscriptions with the Stripe Customer Portal and Netlify Identity.
Stars: ✭ 96 (+146.15%)
Mutual labels:  subscriptions
tg-inviter
Generate personal invite links for Telegram channels
Stars: ✭ 26 (-33.33%)
Mutual labels:  subscriptions
killbill-admin-ui
Kill Bill Administrative UI engine
Stars: ✭ 39 (+0%)
Mutual labels:  subscriptions

AWS AppSync

AWS recently launched AppSync which is in public preview. I have yet to try it my self but it is significantly easier to setup than this package for graphql subscriptions. It also has cool features such as offline support and autoprovisioning of dynamodb tables based on your graphql schema.

graphql-aws-iot-server (serverless and lambda friendly!)

(Work in progress!) Adapted from the Apollo subscriptions-transport-ws to support serverless GraphQL queries, mutations and subscriptions using AWS IoT websockets, lambda functions and an interface to your db of choice.

Architecture Diagram

Architecture Diagram

Functions

SubscriptionManager

The manager publishes all socket messages to ${appPrefix}/in/clientId, where clientId is the unique identifier per client connected on AWS IoT

  • For queries / mutations the manager immediately publishes the result upon processing the query.
  • For subscriptions the following process occurs:
  1. Validate subscription with GraphQLSchema
  2. Store subscription information in DB. You provide the function to store a new subscription to the db. The addSubscription must return a promise on completion. The input parameter to this function is of the following format:
interface Subscription {
  clientId: string;
  query: string;
  subscriptionName: string;
  subscriptionId: string;
  variableValues: { [key: string]: any };
}
  1. The GraphQLServer Package exports a PubSub class which is used to publish a new message. The PubSub class has a publish method which invokes the SubscriptionPublisherFunction. In your GraphQL Schema you invoke the publish method in the same way as you would if you were using the 'servered' subscriptions transport. The method returns a promise to ensure completion.
return pubsub.publish('NEW_TODO', { teamTodoAdded: input }).then(_ => {...});
  1. You are also required to provide a removeSubscriptionFunction that returns a promise on completion. The parameters to this function which are provided by this server package will be subscriptionName and clientId. We recommend having and index to retrieve a subscription based on those properties.

SubscriptionPublisher

The publisher has one public method, executeQueriesAndSendMessages, which takes an array of subscriptions in the same format as they were stored, executes the queries and then publishes the result to the active subscribers. This method returns a promise to ensure completion.

The triggerNameToSubscriptionNamesMap and the triggerNameToFilterFunctionsMap are defined in your own lambda function before invoking the publisher.

  1. Your application Subscription Publisher will get triggerName and payload in the event object.
  2. Use the triggerNameToSubscriptionNamesMap to identify all the subscriptionNames that you need to retrieve subscription rows for.
  3. Retrieve subscriptions from the db. For each subscription pass in the array of subscription rows to the executeQueriesAndSendMessages.
  4. Execute the filterFunction for the triggerName on each row.
  5. For those rows that return true in the filter function, you can run the executeQueriesAndSendMessages with an array of subscriptions and payload as the parameters.
  6. You can choose to run this function in batches as per your application logic.

The database choice and how you choose to batch has been purposely left to the application rather than this helper package for reusability.

Best Practices

  • We recommend using the AWS IoT disconnect lifecycle event to remove active subscriptions from a clientId. See Demo Code for an example of a pruner on the aws iot disconnect event as well as a full working demo.

  • For scale you can publish AWS IoT events to a Kinesis stream which then invokes your SubscriptionManager lambda function

Example App

Demo URL

Source Code

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].