Serverless GraphQL Subscriptions

I recently started working with GraphQL and was able to successfully set it up on AWS Lambda, giving me a "server-side" architecture. However, I would like to use GraphQL subscriptions for more realtime functionality.

I understand that AWS Lambda does not allow WebSockets as connections are only made as long as the function or timeout limit is running.

But is there any way to set up a GraphQL backend so that it can consume subscriptions and store them within AWS services and scale them as a "serverless" application.

Something like using AWS Lambda for GraphQL queries and mutations and then another AWS service for GraphQL subscribers.

+3


source to share


3 answers


AWS AppSync was announced this week (Nov 29) and supports graphQL subscriptions.



+6


source


The only backend service that supports WebSockets on AWS is IoT. I know this name sounds strange, but it works great for web browsers.

You will need to link the AWS IoT SDK in the section to subscribe and publish to topics and use Cognito or IAM to fetch temporary credentials for your tenant. You can set limits so that a client can subscribe / post to a specific topic only.



I don't know exactly how GraphQL subscriptions work, but I assume your clients will subscribe to a topic and every time the data changes, one Lambda function will fire. This Lambda will be able to post a notification on a topic and all clients subscribing to that topic will receive the message.

0


source


I started using google cloud features but then moved to zeit now that islessless but I can use subscriptions as well. Maybe you can take a look there too.

0


source







All Articles