Class: Subscriptions::BaseSubscription

Inherits:
GraphQL::Schema::Subscription
  • Object
show all
Defined in:
app/graphql/subscriptions/base_subscription.rb

Direct Known Subclasses

IssuableUpdated, Notes::Base, WorkItemUpdated

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of BaseSubscription.



8
9
10
11
12
13
# File 'app/graphql/subscriptions/base_subscription.rb', line 8

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

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


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

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



23
24
25
# File 'app/graphql/subscriptions/base_subscription.rb', line 23

def subscribe(*)
  nil
end