Skip to content

Add passive topic listen to Socket#41

Open
michaeljguarino wants to merge 1 commit intomobileoverlord:masterfrom
michaeljguarino:mguarino/channel-listen
Open

Add passive topic listen to Socket#41
michaeljguarino wants to merge 1 commit intomobileoverlord:masterfrom
michaeljguarino:mguarino/channel-listen

Conversation

@michaeljguarino
Copy link
Copy Markdown

Absinthe has a unique protocol on top of pheonix wss to support GraphQl subscriptions, in that each subscription document sent creates a shadow channel that the client then has to manually subscribe to. I couldn't find any existing function to support it using PhoenixClient.Socket so I implemented this, and it seems functional from my testing.

The process to create a working graphql subscription publishing to the current process becomes:

with {:ok, %{"subscriptionId" => id}} <- Channel.push(absinthe, "doc", %{query: query, variables: variables}),
      do: Socket.listen(@socket_name, id, self())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant