Action Policy integration for GraphQL
MIT License
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
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
Published by palkan about 5 years ago
See change log.
Published by palkan over 5 years ago
Initial version.
📑 Documentation