Reputation: 2014
Is it possible to run an Apollo GraphQL Lambda backend with subscriptions? As I understand, GraphQL subscriptions use websockets, so I suppose it won't be possible unless you use Redis as message broker but I want to validate it this as it's not stated in any part of Apollo Docs.
Upvotes: 6
Views: 5353
Reputation: 5025
Someone developed this solution you can find it here aws-lambda-graphql
Edit: you should consider Appsync, it handles subscription
Upvotes: 2
Reputation: 181
Quick 2021 update - it is doable but it's still in the early days and API Gateway has some limitations.
I've put together a project which provides an API almost identical to Apollo server and with docs explaining how to set it up. If you're interested, it's called subscriptionless
Upvotes: 4
Reputation: 157
Yes.
AWS lambdas now have websocket support via API Gateway. The serverless framework also now supports websockets without a plugin, making it really easy to implement.
Upvotes: 12
Reputation: 332
GraphQL subscriptions are not supported with Lambda, Google Cloud functions, or Azure functions or most other serverless vendors. This is because the instance is shutdown when traffic is low, which kills the websocket connection. There are a few experimental setups that have gotten it to work, but I have not tried any of them myself.
You can find more information about this here.
I hope this helps!
Upvotes: 5