Module: Rails::GraphQL::Field::AuthorizedField

Included in:
OutputField
Defined in:
lib/rails/graphql/field/authorized_field.rb

Overview

This provides ways for fields to be authorized, giving a logical level for enabling or disabling access to a field. It has a similar structure to events, but has a different hierarchy of resolution

Defined Under Namespace

Modules: Proxied

Instance Method Summary collapse

Instance Method Details

#authorizable?Boolean

Checks if the field should go through an authorization process

Returns:

  • (Boolean)


32
33
34
# File 'lib/rails/graphql/field/authorized_field.rb', line 32

def authorizable?
  defined?(@authorizer)
end

#authorize(*args, **xargs, &block) ⇒ Object

Add either settings for authorization or a block to be executed. It returns self for chain purposes



21
22
23
24
# File 'lib/rails/graphql/field/authorized_field.rb', line 21

def authorize(*args, **xargs, &block)
  @authorizer = [args, xargs, block]
  self
end

#authorizerObject

Return the settings for the authorize process



27
28
29
# File 'lib/rails/graphql/field/authorized_field.rb', line 27

def authorizer
  @authorizer if authorizable?
end