Exception: GraphQL::UnauthorizedError
- Inherits:
-
RuntimeError
- Object
- StandardError
- Error
- RuntimeError
- GraphQL::UnauthorizedError
- Defined in:
- lib/graphql/unauthorized_error.rb
Overview
When an authorized? hook returns false, this error is used to communicate the failure.
It’s passed to Schema.unauthorized_object.
Alternatively, custom code in authorized? may raise this error. It will be routed the same way.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#ast_nodes ⇒ Object
Returns the value of attribute ast_nodes.
-
#context ⇒ GraphQL::Query::Context
The context for the current query.
-
#object ⇒ Object
readonly
The application object that failed the authorization check.
-
#path ⇒ Object
Returns the value of attribute path.
-
#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.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/graphql/unauthorized_error.rb', line 17 def initialize( = nil, object: nil, type: nil, context: nil) if .nil? && object.nil? && type.nil? raise ArgumentError, "#{self.class.name} requires either a message or keywords" end @path = nil @object = object @type = type @context = context @ast_nodes = nil ||= "An instance of #{object.class} failed #{type.graphql_name}'s authorization check" super() end |
Instance Attribute Details
#ast_nodes ⇒ Object
Returns the value of attribute ast_nodes.
31 32 33 |
# File 'lib/graphql/unauthorized_error.rb', line 31 def ast_nodes @ast_nodes end |
#context ⇒ GraphQL::Query::Context
Returns the context for the current query.
15 16 17 |
# File 'lib/graphql/unauthorized_error.rb', line 15 def context @context end |
#object ⇒ Object (readonly)
Returns the application object that failed the authorization check.
9 10 11 |
# File 'lib/graphql/unauthorized_error.rb', line 9 def object @object end |
#path ⇒ Object
Returns the value of attribute path.
31 32 33 |
# File 'lib/graphql/unauthorized_error.rb', line 31 def path @path end |
#type ⇒ Class (readonly)
Returns the GraphQL object type whose .authorized? method was called (and returned false).
12 13 14 |
# File 'lib/graphql/unauthorized_error.rb', line 12 def type @type end |