Class: GraphQL::Pundit::Instrumenters::Authorization::AuthorizationResolver
- Inherits:
-
Object
- Object
- GraphQL::Pundit::Instrumenters::Authorization::AuthorizationResolver
- Defined in:
- lib/graphql-pundit/instrumenters/authorization.rb
Overview
This does the actual Pundit authorization
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#old_resolver ⇒ Object
readonly
Returns the value of attribute old_resolver.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #call(root, arguments, context) ⇒ Object
-
#initialize(current_user, old_resolver, options) ⇒ AuthorizationResolver
constructor
A new instance of AuthorizationResolver.
Constructor Details
#initialize(current_user, old_resolver, options) ⇒ AuthorizationResolver
Returns a new instance of AuthorizationResolver.
13 14 15 16 17 |
# File 'lib/graphql-pundit/instrumenters/authorization.rb', line 13 def initialize(current_user, old_resolver, ) @current_user = current_user @old_resolver = old_resolver @options = end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
12 13 14 |
# File 'lib/graphql-pundit/instrumenters/authorization.rb', line 12 def current_user @current_user end |
#old_resolver ⇒ Object (readonly)
Returns the value of attribute old_resolver.
12 13 14 |
# File 'lib/graphql-pundit/instrumenters/authorization.rb', line 12 def old_resolver @old_resolver end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/graphql-pundit/instrumenters/authorization.rb', line 12 def @options end |
Instance Method Details
#call(root, arguments, context) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/graphql-pundit/instrumenters/authorization.rb', line 19 def call(root, arguments, context) unless (root, arguments, context) raise ::Pundit::NotAuthorizedError end old_resolver.call(root, arguments, context) rescue ::Pundit::NotAuthorizedError if [:raise] raise GraphQL::ExecutionError, "You're not authorized to do this" end end |