Class: ActionPolicy::GraphQL::AuthorizedField::AuthorizeExtension
- Inherits:
-
Extension
- Object
- GraphQL::Schema::FieldExtension
- Extension
- ActionPolicy::GraphQL::AuthorizedField::AuthorizeExtension
- Defined in:
- lib/action_policy/graphql/authorized_field.rb
Constant Summary collapse
- DEPRECATION_MESSAGE =
"`authorize: *` for mutation fields is deprecated. Please use `preauthorize: *` instead."
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Extension
Class Method Details
.show_authorize_mutation_deprecation ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/action_policy/graphql/authorized_field.rb', line 28 def return if defined?() if defined?(ActiveSupport::Deprecation) ActiveSupport::Deprecation.warn(DEPRECATION_MESSAGE) else warn(DEPRECATION_MESSAGE) end = true end |
Instance Method Details
#after_resolve(value:, context:, object:, **_rest) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/action_policy/graphql/authorized_field.rb', line 48 def after_resolve(value:, context:, object:, **_rest) return value if value.nil? if @raise object. value, to: @to, ** value else object.allowed_to?(@to, value, **) ? value : nil end end |
#apply ⇒ Object
41 42 43 44 45 46 |
# File 'lib/action_policy/graphql/authorized_field.rb', line 41 def apply self.class. if field.mutation && field.mutation < ::GraphQL::Schema::Mutation @to = extract_option(:to) { ::ActionPolicy::GraphQL. } @raise = extract_option(:raise) { ::ActionPolicy::GraphQL. } end |