Class: Subscriptions::BaseSubscription
- Inherits:
-
GraphQL::Schema::Subscription
- Object
- GraphQL::Schema::Subscription
- Subscriptions::BaseSubscription
- Defined in:
- app/graphql/subscriptions/base_subscription.rb
Direct Known Subclasses
Constant Summary collapse
- UNAUTHORIZED_ERROR_MESSAGE =
'Unauthorized subscription'
Instance Method Summary collapse
- #authorized? ⇒ Boolean
-
#initialize(object:, context:, field:) ⇒ BaseSubscription
constructor
A new instance of BaseSubscription.
-
#subscribe ⇒ Object
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.
Constructor Details
#initialize(object:, context:, field:) ⇒ BaseSubscription
Returns a new instance of BaseSubscription.
10 11 12 13 14 15 |
# File 'app/graphql/subscriptions/base_subscription.rb', line 10 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
29 30 31 |
# File 'app/graphql/subscriptions/base_subscription.rb', line 29 def (*) raise NotImplementedError end |
#subscribe ⇒ Object
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
25 26 27 |
# File 'app/graphql/subscriptions/base_subscription.rb', line 25 def subscribe(*) nil end |