Exception: GraphQL::UnauthorizedError
- Defined in:
- lib/graphql/unauthorized_error.rb
Instance Attribute Summary collapse
-
#context ⇒ GraphQL::Query::Context
readonly
The context for the current query.
-
#object ⇒ Object
readonly
The application object that failed the authorization check.
-
#type ⇒ Class
readonly
The GraphQL object type whose
.authorized?
method was called (and returned false).
Instance Method Summary collapse
-
#initialize(message = nil, object: nil, type: nil, context: nil) ⇒ UnauthorizedError
constructor
A new instance of UnauthorizedError.
Constructor Details
#initialize(message = nil, object: nil, type: nil, context: nil) ⇒ UnauthorizedError
Returns a new instance of UnauthorizedError
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/graphql/unauthorized_error.rb', line 13 def initialize( = nil, object: nil, type: nil, context: nil) if .nil? && object.nil? raise ArgumentError, "#{self.class.name} requires either a message or keywords" end @object = object @type = type @context = context ||= "An instance of #{object.class} failed #{type.name}'s authorization check" super() end |
Instance Attribute Details
#context ⇒ GraphQL::Query::Context (readonly)
Returns the context for the current query
11 12 13 |
# File 'lib/graphql/unauthorized_error.rb', line 11 def context @context end |
#object ⇒ Object (readonly)
Returns the application object that failed the authorization check
5 6 7 |
# File 'lib/graphql/unauthorized_error.rb', line 5 def object @object end |
#type ⇒ Class (readonly)
Returns the GraphQL object type whose .authorized?
method was called (and returned false)
8 9 10 |
# File 'lib/graphql/unauthorized_error.rb', line 8 def type @type end |