Module: Rails::GraphQL::Helpers::WithCallbacks

Included in:
Directive, Field::OutputField, Source
Defined in:
lib/rails/graphql/helpers/with_callbacks.rb

Overview

Callbacks is an extension of the events which works with the Callback class, then having extra powers when actually executing the event against Procs or owner-based methods, when provided a symbol

Defined Under Namespace

Modules: Setup

Constant Summary collapse

DEFAULT_EVENT_TYPES =
%i[query mutation subscription request attach
authorize organized prepared finalize prepare subscribed].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(other) ⇒ Object



14
15
16
# File 'lib/rails/graphql/helpers/with_callbacks.rb', line 14

def self.extended(other)
  other.extend(WithCallbacks::Setup)
end

.included(other) ⇒ Object



18
19
20
21
# File 'lib/rails/graphql/helpers/with_callbacks.rb', line 18

def self.included(other)
  other.extend(WithCallbacks::Setup)
  other.delegate(:event_filters, :default_exclusive?, to: :class)
end

Instance Method Details

#on(event_name, *args, unshift: false, **xargs, &block) ⇒ Object

Enhance the event by evolving the block to a Callback object.



65
66
67
68
# File 'lib/rails/graphql/helpers/with_callbacks.rb', line 65

def on(event_name, *args, unshift: false, **xargs, &block)
  block = Callback.new(self, event_name, *args, **xargs, &block)
  super(event_name, block, unshift: unshift)
end