Class: GraphqlChannel
- Inherits:
-
ApplicationCable::Channel
- Object
- ActionCable::Channel::Base
- ApplicationCable::Channel
- GraphqlChannel
- Defined in:
- app/channels/graphql_channel.rb
Overview
This is based on github.com/rmosolgo/graphql-ruby/blob/v1.11.8/lib/graphql/subscriptions/action_cable_subscriptions.rb#L19-L82 modified to work with our own ActionCableLink client
Instance Method Summary collapse
-
#subscribed ⇒ Object
rubocop:disable Gitlab/NamespacedClass.
- #unsubscribed ⇒ Object
Instance Method Details
#subscribed ⇒ Object
rubocop:disable Gitlab/NamespacedClass
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/channels/graphql_channel.rb', line 7 def subscribed @subscription_ids = [] query = params['query'] variables = Gitlab::Graphql::Variables.new(params['variables']).to_h operation_name = params['operationName'] result = GitlabSchema.execute( query, context: context, variables: variables, operation_name: operation_name ) payload = { result: result.to_h, more: result.subscription? } # Track the subscription here so we can remove it # on unsubscribe. @subscription_ids << result.context[:subscription_id] if result.context[:subscription_id] transmit(payload) end |
#unsubscribed ⇒ Object
33 34 35 36 37 |
# File 'app/channels/graphql_channel.rb', line 33 def unsubscribed @subscription_ids.each do |sid| GitlabSchema.subscriptions.delete_subscription(sid) end end |