Useful or not, from you.
absinthe Multiple pushes per client for subscriptions that have a `context_id`


  • Elixir version (elixir -v): 1.11.3 (compiled with Erlang/OTP 23)
  • Absinthe version (mix deps | grep absinthe): 1.6.4

Expected behavior

Publishing to a subscription should result in just a single push per client.

Actual behavior

Using a subscription with a context_id results in the same number of pushes as the number of connected clients, so for example if you have 5 clients connected and you publish to a given subscription, all 5 clients will receive the data 5 times each.

This is not true when there is no context_id

Relevant Schema/Middleware Code

I have created a repository to showcase the problem.

Here is a quick view of schema.ex

defmodule ShowcaseWeb.Schema do
  use Absinthe.Schema

  object :item do
    field :title, :string

  query do

  subscription do
    field :change, :item do
      arg :id, non_null(:id)
      config fn %{id: id}, _ -> {:ok, topic: id, context_id: "global"} end

    field :change_private, :item do
      arg :id, non_null(:id)
      config fn %{id: id}, _ -> {:ok, topic: id} end

    field :change_no_args, :item do
      config fn _, _ -> {:ok, topic: "*", context_id: "global"} end

This is the test case that showcases the behaviour.

I have mentioned this problem on the absinthe_phoenix package as well

That's a useful answer
Without any help

We observe the same behavior and even worse: turning context_id: "global" made messages from adjacent topics leak to the users who weren't subscribed.