Exception: GraphQL::UnauthorizedFieldError

Inherits:
UnauthorizedError show all
Defined in:
lib/graphql/unauthorized_field_error.rb

Instance Attribute Summary collapse

Attributes inherited from UnauthorizedError

#context, #object, #type

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, object: nil, type: nil, context: nil, field: nil) ⇒ UnauthorizedFieldError


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/graphql/unauthorized_field_error.rb', line 7

def initialize(message = nil, object: nil, type: nil, context: nil, field: nil)
  if message.nil? && [field, type].any?(&:nil?)
    raise ArgumentError, "#{self.class.name} requires either a message or keywords"
  end

  @field = field
  message ||= begin
    if object
      "An instance of #{object.class} failed #{type.name}'s authorization check on field #{field.name}"
    else
      "Failed #{type.name}'s authorization check on field #{field.name}"
    end
  end
  super(message, object: object, type: type, context: context)
end

Instance Attribute Details

#fieldField


5
6
7
# File 'lib/graphql/unauthorized_field_error.rb', line 5

def field
  @field
end