GraphQL subscriptions, Absinthe and Phoenix channels

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 :thinking:

1 Like

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.

5 Likes

@benwilson512 thanks so much! I didn’t know Absinthe has such collection of integrations with client GraphQL frameworks, looks awesome!

Are you aware of any such libraries for mobile platforms, specifically native Android and iOS?

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.

Thanks again, I’ll check it out :slightly_smiling_face:

Apollo has clients for Android and iOS.


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.

1 Like

Thanks @easco, that’s really helpful! I will check out the repo :slightly_smiling_face:

@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 :pensive:

3 Likes

@easco Would you happen to have an example integrating your repo into Phoenix? Would be super helpful. Thx!