Class: Subscriptions::BaseSubscription

Inherits:
GraphQL::Schema::Subscription
  • Object
show all
Includes:
Gitlab::Graphql::VersionFilter::FutureFieldFallback
Defined in:
app/graphql/subscriptions/base_subscription.rb

Constant Summary collapse

UNAUTHORIZED_ERROR_MESSAGE =
'Unauthorized subscription'

Instance Method Summary collapse

Constructor Details

#initialize(object:, context:, field:) ⇒ BaseSubscription



12
13
14
15
16
17
# File 'app/graphql/subscriptions/base_subscription.rb', line 12

def initialize(object:, context:, field:)
  super

  # Reset user so that we don't use a stale user for authorization
  current_user.reset if current_user
end

Instance Method Details

#authorized?Boolean

Raises:

  • (NotImplementedError)


31
32
33
# File 'app/graphql/subscriptions/base_subscription.rb', line 31

def authorized?(*)
  raise NotImplementedError
end

#subscribeObject

We override graphql-ruby’s default ‘subscribe` since it returns :no_response instead, which leads to empty hashes rendered out to the caller which has caused problems in the client.

Eventually, we should move to an approach where the caller receives a response here upon subscribing, but we don’t need this currently because Vue components also perform an initial fetch query. See gitlab.com/gitlab-org/gitlab/-/issues/402614



27
28
29
# File 'app/graphql/subscriptions/base_subscription.rb', line 27

def subscribe(*)
  nil
end