debian-mirror-gitlab/app/graphql/resolvers/group_milestones_resolver.rb

32 lines
944 B
Ruby
Raw Normal View History

2020-10-24 23:57:45 +05:30
# frozen_string_literal: true
2021-01-29 00:20:46 +05:30
# rubocop:disable Graphql/ResolverType (inherited from MilestonesResolver)
2020-10-24 23:57:45 +05:30
module Resolvers
class GroupMilestonesResolver < MilestonesResolver
argument :include_descendants, GraphQL::BOOLEAN_TYPE,
required: false,
2021-03-08 18:12:59 +05:30
description: 'Also return milestones in all subgroups and subprojects.'
2020-10-24 23:57:45 +05:30
2021-01-29 00:20:46 +05:30
type Types::MilestoneType.connection_type, null: true
2020-10-24 23:57:45 +05:30
private
def parent_id_parameters(args)
return { group_ids: parent.id } unless args[:include_descendants].present?
{
group_ids: parent.self_and_descendants.public_or_visible_to_user(current_user).select(:id),
project_ids: group_projects.with_issues_or_mrs_available_for_user(current_user)
}
end
def group_projects
GroupProjectsFinder.new(
group: parent,
current_user: current_user,
options: { include_subgroups: true }
).execute
end
end
end