diff --git a/lib/hq/graphql.rb b/lib/hq/graphql.rb index 0f2a506..4e359a8 100644 --- a/lib/hq/graphql.rb +++ b/lib/hq/graphql.rb @@ -20,8 +20,8 @@ def self.configure(&block) config.instance_eval(&block) end - def self.authorized?(action, object, context) - !config.authorize || config.authorize.call(action, object, context) + def self.authorized?(action, object, context, **args) + !config.authorize || config.authorize.call(action, object, context, **args) end def self.authorize_field(action, field, object, context) diff --git a/lib/hq/graphql/ext/object_extensions.rb b/lib/hq/graphql/ext/object_extensions.rb index c53c428..263674b 100644 --- a/lib/hq/graphql/ext/object_extensions.rb +++ b/lib/hq/graphql/ext/object_extensions.rb @@ -25,8 +25,8 @@ def authorize_action(action) self.authorized_action = action end - def authorized?(object, context) - super && ::HQ::GraphQL.authorized?(authorized_action, object, context) + def authorized?(object, context, **args) + super && ::HQ::GraphQL.authorized?(authorized_action, object, context, **args) end def with_model(model_name, attributes: true, associations: true, auto_nil: true, enums: true) diff --git a/lib/hq/graphql/resource/auto_mutation.rb b/lib/hq/graphql/resource/auto_mutation.rb index 7a7c8e4..7984ce3 100644 --- a/lib/hq/graphql/resource/auto_mutation.rb +++ b/lib/hq/graphql/resource/auto_mutation.rb @@ -43,6 +43,7 @@ def build_update if resource resource.assign_attributes(args[:attributes].format_nested_attributes) + scoped_self.after_assign_attributes(resource, args[:attributes], context) if scoped_self&.respond_to?(:after_assign_attributes) if resource.save { resource: resource, @@ -135,7 +136,7 @@ def build_mutation(action:, require_primary_key: false, nil_klass: false, &block graphql_name gql_name define_method(:ready?) do |**args| - super(**args) && ::HQ::GraphQL.authorized?(action, scoped_model_name, context) + super(**args) && ::HQ::GraphQL.authorized?(action, scoped_model_name, context, **args) end lazy_load do diff --git a/lib/hq/graphql/version.rb b/lib/hq/graphql/version.rb index df82d51..df50950 100644 --- a/lib/hq/graphql/version.rb +++ b/lib/hq/graphql/version.rb @@ -2,6 +2,6 @@ module HQ module GraphQL - VERSION = "2.3.6" + VERSION = "2.3.7" end end