Module: GraphQL::Streaming::ActionCableChannel

Defined in:
lib/graphql/streaming/action_cable_channel.rb

Overview

TODO: This contains MONKEYPATCHES to support stopping certain streams

Instance Method Summary collapse

Instance Method Details

#send_graphql_payload(payload) ⇒ Object

Work around the fact that ‘transmit` is private



24
25
26
# File 'lib/graphql/streaming/action_cable_channel.rb', line 24

def send_graphql_payload(payload)
  transmit(payload)
end

#stop_specific_streams(streams_to_stop) ⇒ Object

Stop streams which were captured from stream_from



13
14
15
16
17
18
19
20
21
# File 'lib/graphql/streaming/action_cable_channel.rb', line 13

def stop_specific_streams(streams_to_stop)
  @_streams ||= []
  @_streams -= streams_to_stop
  streams_to_stop.each do |broadcasting, callback|
    pubsub.unsubscribe broadcasting, callback
    logger.info "#{self.class.name} stopped streaming from #{broadcasting}"
  end
  nil
end

#stream_from(*args, &block) ⇒ Object

MONKEY PATCH Return the newly-created stream, so you can stop it later



7
8
9
10
# File 'lib/graphql/streaming/action_cable_channel.rb', line 7

def stream_from(*args, &block)
  super
  streams.last
end