apollo-server-micro enable subscriptions

Created on 2 May 2019  ·  10Comments  ·  Source: apollographql/apollo-server

Hi, I am trying to move the api to apollo-server-micro, for some reason subscriptions gets disabled or maybe they are not implemented yet with micro, before I was using the standalone apollo-server package and subscriptions were just working, can you help me :) ?

bug 🖇️ micro 🧬 subscriptions

Most helpful comment

@SirensOfTitan Can you share how you got graphql subscriptions with next.js? I've been stuck on this for days.

All 10 comments

Hi @julianux , I too am using apollo-micro-server and I was wondering if anyone came up with a hack to solve this. My hypothesis is that apollo-server needs internal state to keep a track of the clients that are listening for a subscription and for this reason, it is not possible to use subscriptions with micro (which is more like a lambda and not a running server with state).

That being said, maybe there is some clever solution out there that could make this work?

I don't suspect this has anything to do with state requirements. That said, both of your help in looking into this would be greatly appreciated. Given the very small usage rate of the apollo-server-micro package, I'm not sure many users are actively using subscriptions _and_ micro.

The contribution which enabled micro did claim to provide subscriptions support, but again, your help would be appreciated in debugging it.

Thanks for reporting this issue originally!

I'm going to close this issue since it hasn't received a lot of traction and could have been resolved already.

If this is still a problem, would someone who's experiencing the problem (or anyone who comes across this issue and is able to assist) mind building a reproduction of the problem in to a runnable CodeSandbox reproduction using the latest version of Apollo Server and sharing the link to that CodeSandbox in this issue?

I'm happy to re-open if this is still occurring and someone can provide a reproduction. Thanks again!

For those flowing in from Google, here's an example of subscriptions working successfully with micro:
https://codesandbox.io/embed/apollo-server-gnt97

@SirensOfTitan did you bypass the micro? did you test it with any other micro routes + GraphQL handler?

@berkaey: I'm using this primarily in a next.js app with some other routes and a graphql handler, although that implementation required a lot more effort than the sandbox I shared above. Happy to put together an example for that if it would be helpful.

Ditched the micro on this projects and kept the express version for this project but I would like to see the implementation 👍

@berkaey: I'm using this primarily in a next.js app with some other routes and a graphql handler, although that implementation required a lot more effort than the sandbox I shared above. Happy to put together an example for that if it would be helpful.

How connect your nextjs apollo server micro with apollo client(subscription)??

Can I show your example code about nextjs apollo server?

@SirensOfTitan Can you share how you got graphql subscriptions with next.js? I've been stuck on this for days.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dupski picture dupski  ·  3Comments

mathroc picture mathroc  ·  3Comments

manuelfink picture manuelfink  ·  3Comments

bryanerayner picture bryanerayner  ·  3Comments

veeramarni picture veeramarni  ·  3Comments