palkan/action_policy-graphql

AuthorizedField is included (prepended) multiple time into field class

rzaharenkov opened this issue · 0 comments

Tell us about your environment

Ruby Version: 2.6

Framework Version (Rails, whatever): Rails

Action Policy Version: 0.4.4

Action Policy GraphQL Version: 0.4.0

What did you do?

We are trying to combine action_policy-graphql with other custom extensions.

What did you expect to happen?

My custom extension is used for authentication and it is supposed to run before authentication. I have my extension injected inside field class and I expect that base field initialize method runs before initialize method of any module included into it.

What actually happened?

I can see that AuthorizedField is included multiple times and it's initialize method is called before initialize method defined in class:

> self.class.ancestors
=> [ActionPolicy::GraphQL::AuthorizedField,
 Types::BaseField,
 ActionPolicy::GraphQL::AuthorizedField,
 GraphQL::Schema::Member::AcceptsDefinition::InitializeExtension,
 GraphQL::Schema::Member::AcceptsDefinition::ToGraphQLExtension,
 GraphQL::Schema::Field,
 GraphQL::Schema::FindInheritedValue::EmptyObjects,
 GraphQL::Schema::Member::HasPath,
 GraphQL::Schema::Member::HasAstNode,
 GraphQL::Schema::Member::HasArguments::ArgumentObjectLoader,
 GraphQL::Schema::Member::HasArguments,
 GraphQL::Schema::Member::AcceptsDefinition,
 GraphQL::Schema::Member::CachedGraphQLDefinition,
 ActiveSupport::ToJsonWithActiveSupportEncoder,
 Object,
 Nori::CoreExt::Object,
 FriendlyId::ObjectUtils,
 RequireAll,
 PP::ObjectMixin,
 JSON::Ext::Generator::GeneratorMethods::Object,
 ActiveSupport::Tryable,
 ActiveSupport::Dependencies::Loadable,
 Kernel,
 BasicObject]