bjunc / apollo-link-phx-ws

Phoenix websocket link for Apollo 2.0
7 stars 1 forks source link

I wish compatibility with subscriptions #3

Open Yamilquery opened 6 years ago

Yamilquery commented 6 years ago

I've searching during all my day how to use Phoenix Absinthe subscriptions websocket with a react native application, using react-apollo, but I can't find nothing that works.

Somebody knows any option to do that?

Thank you so much!

bjunc commented 6 years ago

I haven't looked into doing subscriptions yet. I believe the Absinthe team has though, with their recent Apollo libs. Might want to check them out:

@absinthe/socket-apollo-link

Yamilquery commented 6 years ago

Thank you for your answer, I've check that library already. However I can't make it work. I will try again and I'll tell you!

bjunc commented 6 years ago

Just out of curiosity, what's your use case for graphql pubsub?

Yamilquery commented 6 years ago

We need to make a chat application and other real-time functionality that will be added, but we are stopped, because a lack of documentation about how to connect Elixir Absinthe with React Apollo using Websockets with subscriptions.

Could you recommend an alternative? Personally I would love to be able to use subscriptions!

bjunc commented 6 years ago

Hmm. If it turns out you can't get the Absinthe team's lib working, and mine doesn't support PubSub yet, another option would be to create a general purpose Phoenix socket, and then pass that socket into this lib via options.socket. That would allow you to at least repurpose one socket connection for GraphQL over socket, and then regular channels for your chat. You could even build a plug (similar to the tracing plug) that sent a regular channel message based on a GraphQL mutation.

I can look into the PubSub logic to get you up and running.

Yamilquery commented 6 years ago

Thank you so much for your answer. Your proposal sounds pretty good, but I still do not consider myself an Elixir Phoenix expert, but right now I'll start researching to do it that way.

It would be great if this module was compatible with PubSub!

Edit:

I just managed to run the @absinthe/socket-apollo-link library that you recommended me. In a moment I will test with subscriptions and setContext and I'll tell you!

Yamilquery commented 6 years ago

Finally I got with @absinthe/socket-apollo-link

Even I wrote a tutorial in medium.

https://medium.com/@yamildazaguirre/how-to-integrate-elixir-absinthe-graphql-with-react-apollo-without-dying-in-the-attempt-2b5c1cc59577