Does anyone know of any resources on how GraphQL subscriptions are implemented in Absinthe? Specifically, I’m wondering how the GraphQL subscription protocol looks like and how it makes use of Phoenix channels.
GraphiQL is able to set up a subscription to Absinthe/Phoenix socket, and I’m not sure how it works without knowledge of the channels protocol
Hey @arkgil! Great questions. https://github.com/absinthe-graphql/absinthe-socket provides various integrations with Apollo, Relay, or plain JS that ultimately wrap Phoenix.js. The various GraphiQL UIs generally provide the ability to swap out how network calls are made, so we just swap in the relevant absinthe-socket implementation, and it calls Phoenix.js functions.
I am not off the top of my head sorry. I do know that both of those platforms have working phoenix channel client implementations. Using GraphQL on top of that isn’t a particularly challenging thing, you can check out the Absinthe.Phoenix tests for example usage.
But Apollo uses a different Web Socket protocol than AbsinthePhoenix to handle communication.
I started an adapter to integrate the Apollo protocol with Absinthe that you can find here:
But at this point it is out-of-date with phoenix and it never was driven to completion. Caveat Emptor but it’s there if you care to look at it.
@arkgil I spent some time today updating the repo. It now works with Cowboy 2 (2.6 to be more accurate). I still need to create an example that shows integrating it into a Phoenix app though