class HQ::GraphQL::Field

Attributes

authorize[R]
authorize_action[R]

Public Class Methods

new(*args, authorize_action: :read, authorize: nil, klass: nil, **options, &block) click to toggle source
Calls superclass method
# File lib/hq/graphql/field.rb, line 8
def initialize(*args, authorize_action: :read, authorize: nil, klass: nil, **options, &block)
  super(*args, **options, &block)
  @authorize_action = authorize_action
  @authorize = authorize
  @klass_or_string = klass
end

Public Instance Methods

authorized?(object, _args, ctx) click to toggle source
Calls superclass method
# File lib/hq/graphql/field.rb, line 23
def authorized?(object, _args, ctx)
  super &&
    (!authorize || authorize.call(object, ctx)) &&
    ::HQ::GraphQL.authorize_field(authorize_action, self, object, ctx)
end
klass() click to toggle source
# File lib/hq/graphql/field.rb, line 29
def klass
  @klass ||= @klass_or_string.is_a?(String) ? @klass_or_string.constantize : @klass_or_string
end
scope(&block) click to toggle source
# File lib/hq/graphql/field.rb, line 15
def scope(&block)
  if block
    @scope = block
  else
    @scope
  end
end