2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
module Resolvers
|
2019-07-07 11:18:12 +05:30
|
|
|
class MergeRequestsResolver < BaseResolver
|
2020-06-23 00:09:42 +05:30
|
|
|
include ResolvesMergeRequests
|
2021-04-29 21:17:54 +05:30
|
|
|
extend ::Gitlab::Graphql::NegatableArguments
|
2020-06-23 00:09:42 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
type ::Types::MergeRequestType.connection_type, null: true
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
alias_method :project, :object
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
def self.accept_assignee
|
2021-10-27 15:23:28 +05:30
|
|
|
argument :assignee_username, GraphQL::Types::String,
|
2021-04-29 21:17:54 +05:30
|
|
|
required: false,
|
|
|
|
description: 'Username of the assignee.'
|
2021-01-03 14:25:43 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def self.accept_author
|
2021-10-27 15:23:28 +05:30
|
|
|
argument :author_username, GraphQL::Types::String,
|
2021-04-29 21:17:54 +05:30
|
|
|
required: false,
|
|
|
|
description: 'Username of the author.'
|
2021-01-03 14:25:43 +05:30
|
|
|
end
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
def self.accept_reviewer
|
2021-10-27 15:23:28 +05:30
|
|
|
argument :reviewer_username, GraphQL::Types::String,
|
2021-04-29 21:17:54 +05:30
|
|
|
required: false,
|
|
|
|
description: 'Username of the reviewer.'
|
2021-02-22 17:27:13 +05:30
|
|
|
end
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
argument :iids, [GraphQL::Types::String],
|
2021-04-29 21:17:54 +05:30
|
|
|
required: false,
|
|
|
|
description: 'Array of IIDs of merge requests, for example `[1, 2]`.'
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
argument :source_branches, [GraphQL::Types::String],
|
2020-06-23 00:09:42 +05:30
|
|
|
required: false,
|
|
|
|
as: :source_branch,
|
2021-04-29 21:17:54 +05:30
|
|
|
description: <<~DESC
|
|
|
|
Array of source branch names.
|
|
|
|
All resolved merge requests will have one of these branches as their source.
|
|
|
|
DESC
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
argument :target_branches, [GraphQL::Types::String],
|
2020-06-23 00:09:42 +05:30
|
|
|
required: false,
|
|
|
|
as: :target_branch,
|
2021-04-29 21:17:54 +05:30
|
|
|
description: <<~DESC
|
|
|
|
Array of target branch names.
|
|
|
|
All resolved merge requests will have one of these branches as their target.
|
|
|
|
DESC
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
argument :state, ::Types::MergeRequestStateEnum,
|
|
|
|
required: false,
|
2021-11-11 11:23:49 +05:30
|
|
|
description: 'Merge request state. If provided, all resolved merge requests will have this state.'
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2022-03-02 08:16:31 +05:30
|
|
|
argument :draft, GraphQL::Types::Boolean,
|
|
|
|
required: false,
|
|
|
|
description: 'Limit result to draft merge requests.'
|
|
|
|
|
2023-06-20 00:43:36 +05:30
|
|
|
argument :approved, GraphQL::Types::Boolean,
|
|
|
|
required: false,
|
|
|
|
description: <<~DESC
|
|
|
|
Limit results to approved merge requests.
|
|
|
|
Available only when the feature flag `mr_approved_filter` is enabled.
|
|
|
|
DESC
|
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
argument :created_after, Types::TimeType,
|
|
|
|
required: false,
|
|
|
|
description: 'Merge requests created after this timestamp.'
|
|
|
|
argument :created_before, Types::TimeType,
|
|
|
|
required: false,
|
|
|
|
description: 'Merge requests created before this timestamp.'
|
|
|
|
argument :updated_after, Types::TimeType,
|
|
|
|
required: false,
|
|
|
|
description: 'Merge requests updated after this timestamp.'
|
|
|
|
argument :updated_before, Types::TimeType,
|
|
|
|
required: false,
|
|
|
|
description: 'Merge requests updated before this timestamp.'
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
argument :labels, [GraphQL::Types::String],
|
2020-06-23 00:09:42 +05:30
|
|
|
required: false,
|
|
|
|
as: :label_name,
|
|
|
|
description: 'Array of label names. All resolved merge requests will have all of these labels.'
|
2020-10-24 23:57:45 +05:30
|
|
|
argument :merged_after, Types::TimeType,
|
2020-11-24 15:15:51 +05:30
|
|
|
required: false,
|
2021-03-08 18:12:59 +05:30
|
|
|
description: 'Merge requests merged after this date.'
|
2020-10-24 23:57:45 +05:30
|
|
|
argument :merged_before, Types::TimeType,
|
2020-11-24 15:15:51 +05:30
|
|
|
required: false,
|
2021-03-08 18:12:59 +05:30
|
|
|
description: 'Merge requests merged before this date.'
|
2021-10-27 15:23:28 +05:30
|
|
|
argument :milestone_title, GraphQL::Types::String,
|
2020-11-24 15:15:51 +05:30
|
|
|
required: false,
|
2021-03-08 18:12:59 +05:30
|
|
|
description: 'Title of the milestone.'
|
2020-11-24 15:15:51 +05:30
|
|
|
argument :sort, Types::MergeRequestSortEnum,
|
2021-03-08 18:12:59 +05:30
|
|
|
description: 'Sort merge requests by this criteria.',
|
2020-11-24 15:15:51 +05:30
|
|
|
required: false,
|
2021-02-22 17:27:13 +05:30
|
|
|
default_value: :created_desc
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
negated do
|
2021-10-27 15:23:28 +05:30
|
|
|
argument :labels, [GraphQL::Types::String],
|
2021-04-29 21:17:54 +05:30
|
|
|
required: false,
|
|
|
|
as: :label_name,
|
|
|
|
description: 'Array of label names. All resolved merge requests will not have these labels.'
|
2021-10-27 15:23:28 +05:30
|
|
|
argument :milestone_title, GraphQL::Types::String,
|
2021-04-29 21:17:54 +05:30
|
|
|
required: false,
|
|
|
|
description: 'Title of the milestone.'
|
|
|
|
end
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
def self.single
|
|
|
|
::Resolvers::MergeRequestResolver
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
def no_results_possible?(args)
|
|
|
|
project.nil? || some_argument_is_empty?(args)
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
def some_argument_is_empty?(args)
|
|
|
|
args.values.any? { |v| v.is_a?(Array) && v.empty? }
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|