Skip to content

0.5.0

Latest
Compare
Choose a tag to compare
@palkan palkan released this 07 Oct 11:30
· 29 commits to master since this release

Features

New configuration options to control exceptions behaviour

Two new configuration options have been added:

  • preauthorize_raise_exception: similar to authorize_raise_exception but for preauthorize: true fields; fallbacks to authorize_raise_exception unless explicitly specified.

  • preauthorize_mutation_raise_exception: similar to preauthorize_raise_exception but only for mutations; fallbacks to preauthorize_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