Class: GraphQR::PermittedFieldsExtension

Inherits:
GraphQL::Schema::FieldExtension
  • Object
show all
Defined in:
lib/graphqr/permitted_fields_extension.rb

Overview

This is an extension used on the ‘GraphQR::Fields::BaseField`.

It is responsible for authorizing each field within a query. It searches if the field is defined on the ‘permitted_fields` method of the policy

Instance Method Summary collapse

Instance Method Details

#resolve(object:, arguments:, context:) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/graphqr/permitted_fields_extension.rb', line 10

def resolve(object:, arguments:, context:)
  if authorized?(object, context)
    yield(object, arguments, nil)
  else
    on_unauthorized
  end
end