class GraphQL::Subscriptions::Instrumentation::SubscriptionRegistrationResolve
Public Class Methods
new(inner_proc)
click to toggle source
# File lib/graphql/subscriptions/instrumentation.rb, line 40 def initialize(inner_proc) @inner_proc = inner_proc end
Public Instance Methods
call(obj, args, ctx)
click to toggle source
Wrap the proc with subscription registration logic
# File lib/graphql/subscriptions/instrumentation.rb, line 45 def call(obj, args, ctx) result = nil if @inner_proc && !@inner_proc.is_a?(GraphQL::Field::Resolve::BuiltInResolve) result = @inner_proc.call(obj, args, ctx) end 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, ) result elsif ctx.irep_node.subscription_topic == ctx.query.subscription_topic if !result.nil? result elsif obj.is_a?(GraphQL::Schema::Object) # The root object is _already_ the subscription update: obj.object else obj end else # This is a subscription update, but this event wasn't triggered. ctx.skip end end