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
Constant Summary
Constants included from Gitlab::Auth::AuthFinders
Gitlab::Auth::AuthFinders::DEPLOY_TOKEN_HEADER, Gitlab::Auth::AuthFinders::HEADER_TOKEN_KEYS, Gitlab::Auth::AuthFinders::JOB_TOKEN_HEADER, Gitlab::Auth::AuthFinders::JOB_TOKEN_PARAM, Gitlab::Auth::AuthFinders::PARAM_TOKEN_KEYS, Gitlab::Auth::AuthFinders::PATH_DEPENDENT_FEED_TOKEN_REGEX, Gitlab::Auth::AuthFinders::PRIVATE_TOKEN_HEADER, Gitlab::Auth::AuthFinders::PRIVATE_TOKEN_PARAM, Gitlab::Auth::AuthFinders::RUNNER_JOB_TOKEN_PARAM, Gitlab::Auth::AuthFinders::RUNNER_TOKEN_PARAM
Instance Method Summary collapse
-
#subscribed ⇒ Object
rubocop:disable Gitlab/NamespacedClass.
- #unsubscribed ⇒ Object
Methods inherited from ApplicationCable::Channel
#authorization_scopes, #validate_token_scope
Methods included from Gitlab::Auth::AuthFinders
#authentication_token_present?, #cluster_agent_token_from_authorization_token, #deploy_token_from_request, #find_runner_from_token, #find_user_from_access_token, #find_user_from_basic_auth_password, #find_user_from_bearer_token, #find_user_from_feed_token, #find_user_from_job_token, #find_user_from_lfs_token, #find_user_from_personal_access_token, #find_user_from_static_object_token, #find_user_from_warden, #find_user_from_web_access_token, #validate_and_save_access_token!
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 |