Features
New configuration options to control exceptions behaviour
Two new configuration options have been added:
-
preauthorize_raise_exception
: similar toauthorize_raise_exception
but forpreauthorize: true
fields; fallbacks toauthorize_raise_exception
unless explicitly specified. -
preauthorize_mutation_raise_exception
: similar topreauthorize_raise_exception
but only for mutations; fallbacks topreauthorize_raise_exception
unless explicitly specified.
By defining this options you can, for example, configure Action Policy to return nulls for queries and raise exceptions for mutation fields when using authorize: *
and preauthorize: *
options:
# The default value for all authorize: * fields
ActionPolicy::GraphQL.authorize_raise_exception = true
# The default value for all preauthorize: * fields
ActionPolicy::GraphQL.preauthorize_raise_exception = false
# Override preauthorize: * behaviour for mutations
ActionPolicy::GraphQL.preauthorize_raise_exception = true
Specify custom field options for expose_authorization_rules
Now you can add additional options for underflying field
call via field_options
parameter:
expose_authorization_rules :show?, field_options: {camelize: false}
# equals to
field :can_show, ActionPolicy::GraphQL::Types::AuthorizationResult, null: false, camelize: false