Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apollo Server + Lambda + Subscriptions

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.

like image 614
Tim Givois Avatar asked Dec 04 '22 19:12

Tim Givois


2 Answers

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.

like image 66
Paddy Hamilton Avatar answered Dec 06 '22 09:12

Paddy Hamilton


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!

like image 35
Cory McAboy Avatar answered Dec 06 '22 08:12

Cory McAboy