Exception: GraphQL::UnauthorizedFieldError
- Inherits:
-
UnauthorizedError
- Object
- StandardError
- Error
- UnauthorizedError
- GraphQL::UnauthorizedFieldError
- Defined in:
- lib/graphql/unauthorized_field_error.rb
Instance Attribute Summary collapse
-
#field ⇒ Field
The field that failed the authorization check.
Attributes inherited from UnauthorizedError
Instance Method Summary collapse
-
#initialize(message = nil, object: nil, type: nil, context: nil, field: nil) ⇒ UnauthorizedFieldError
constructor
A new instance of UnauthorizedFieldError.
Constructor Details
#initialize(message = nil, object: nil, type: nil, context: nil, field: nil) ⇒ UnauthorizedFieldError
Returns a new instance of 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( = nil, object: nil, type: nil, context: nil, field: nil) if .nil? && [field, type].any?(&:nil?) raise ArgumentError, "#{self.class.name} requires either a message or keywords" end @field = field ||= 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(, object: object, type: type, context: context) end |
Instance Attribute Details
#field ⇒ Field
Returns the field that failed the authorization check
5 6 7 |
# File 'lib/graphql/unauthorized_field_error.rb', line 5 def field @field end |