Welcome to mirror list, hosted at ThFree Co, Russian Federation.

project_milestones_resolver.rb « resolvers « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c88c9ce7219dd0563700d07a79e7194cbcaacd4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true
# rubocop:disable Graphql/ResolverType (inherited from MilestonesResolver)

module Resolvers
  class ProjectMilestonesResolver < MilestonesResolver
    argument :include_ancestors, GraphQL::BOOLEAN_TYPE,
             required: false,
             description: "Also return milestones in the project's parent group and its ancestors"

    type Types::MilestoneType.connection_type, null: true

    private

    def parent_id_parameters(args)
      return { project_ids: parent.id } unless args[:include_ancestors].present? && parent.group.present?

      {
        group_ids: parent.group.self_and_ancestors.select(:id),
        project_ids: parent.id
      }
    end
  end
end