Commit f5da5e70 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Refactor GroupIssuableResolver module

Adds the arguments when included since these are expected to be always
present for group issuables
parent a7fde3da
...@@ -3,19 +3,21 @@ ...@@ -3,19 +3,21 @@
module GroupIssuableResolver module GroupIssuableResolver
extend ActiveSupport::Concern extend ActiveSupport::Concern
class_methods do included do
def include_subgroups(name_of_things) argument :include_subgroups, GraphQL::Types::Boolean,
argument :include_subgroups, GraphQL::Types::Boolean, required: false,
required: false, default_value: false,
default_value: false, description: "Include #{issuable_collection_name} belonging to subgroups"
description: "Include #{name_of_things} belonging to subgroups"
end
def non_archived(name_of_things) argument :non_archived, GraphQL::Types::Boolean,
argument :non_archived, GraphQL::Types::Boolean, required: false,
required: false, default_value: true,
default_value: true, description: "Return #{issuable_collection_name} from non archived projects"
description: "Return #{name_of_things} from non archived projects" end
end
def resolve(**args)
args[:non_archived] = !args.delete(:include_archived)
super
end end
end end
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
module Resolvers module Resolvers
class GroupIssuesResolver < BaseIssuesResolver class GroupIssuesResolver < BaseIssuesResolver
include GroupIssuableResolver def self.issuable_collection_name
'issues'
end
include_subgroups 'issues' include GroupIssuableResolver
non_archived 'issues'
def ready?(**args) def ready?(**args)
if args.dig(:not, :release_tag).present? if args.dig(:not, :release_tag).present?
......
...@@ -2,14 +2,16 @@ ...@@ -2,14 +2,16 @@
module Resolvers module Resolvers
class GroupMergeRequestsResolver < MergeRequestsResolver class GroupMergeRequestsResolver < MergeRequestsResolver
def self.issuable_collection_name
'merge requests'
end
include GroupIssuableResolver include GroupIssuableResolver
alias_method :group, :object alias_method :group, :object
type Types::MergeRequestType.connection_type, null: true type Types::MergeRequestType.connection_type, null: true
include_subgroups 'merge requests'
non_archived 'merge requests'
accept_assignee accept_assignee
accept_author accept_author
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment