Class: GraphQL::Subscriptions::Instrumentation::SubscriptionRegistrationResolve
- Inherits:
-
Object
- Object
- GraphQL::Subscriptions::Instrumentation::SubscriptionRegistrationResolve
- Defined in:
- lib/graphql/subscriptions/instrumentation.rb
Instance Method Summary collapse
-
#call(obj, args, ctx) ⇒ Object
Wrap the proc with subscription registration logic.
-
#initialize(inner_proc) ⇒ SubscriptionRegistrationResolve
constructor
A new instance of SubscriptionRegistrationResolve.
Constructor Details
#initialize(inner_proc) ⇒ SubscriptionRegistrationResolve
Returns a new instance of SubscriptionRegistrationResolve
41 42 43 |
# File 'lib/graphql/subscriptions/instrumentation.rb', line 41 def initialize(inner_proc) @inner_proc = inner_proc end |
Instance Method Details
#call(obj, args, ctx) ⇒ Object
Wrap the proc with subscription registration logic
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/graphql/subscriptions/instrumentation.rb', line 46 def call(obj, args, ctx) @inner_proc.call(obj, args, ctx) if @inner_proc && !@inner_proc.is_a?(GraphQL::Field::Resolve::BuiltInResolve) events = ctx.namespace(:subscriptions)[:events] if events # This is the first execution, so gather an Event # for the backend to register: events << Subscriptions::Event.new( name: ctx.field.name, arguments: args, context: ctx, ) ctx.skip elsif ctx.irep_node.subscription_topic == ctx.query.subscription_topic # The root object is _already_ the subscription update: if obj.is_a?(GraphQL::Schema::Object) obj.object else obj end else # This is a subscription update, but this event wasn't triggered. ctx.skip end end |