2018-09-11 15:08:34 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-23 03:55:14 -04:00
|
|
|
module Resolvers
|
2019-01-30 14:00:30 -05:00
|
|
|
class MergeRequestsResolver < BaseResolver
|
2020-05-21 20:08:07 -04:00
|
|
|
include ResolvesMergeRequests
|
2021-04-07 14:09:45 -04:00
|
|
|
extend ::Gitlab::Graphql::NegatableArguments
|
2020-05-21 20:08:07 -04:00
|
|
|
|
2020-12-14 13:09:48 -05:00
|
|
|
type ::Types::MergeRequestType.connection_type, null: true
|
|
|
|
|
2021-03-18 02:11:52 -04:00
|
|
|
alias_method :project, :object
|
2018-05-23 03:55:14 -04:00
|
|
|
|
2020-10-05 14:08:51 -04:00
|
|
|
def self.accept_assignee
|
2021-07-22 08:10:04 -04:00
|
|
|
argument :assignee_username, GraphQL::Types::String,
|
2021-03-23 23:09:04 -04:00
|
|
|
required: false,
|
|
|
|
description: 'Username of the assignee.'
|
2020-10-05 14:08:51 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.accept_author
|
2021-07-22 08:10:04 -04:00
|
|
|
argument :author_username, GraphQL::Types::String,
|
2021-03-23 23:09:04 -04:00
|
|
|
required: false,
|
|
|
|
description: 'Username of the author.'
|
2020-10-05 14:08:51 -04:00
|
|
|
end
|
|
|
|
|
2020-12-10 07:09:43 -05:00
|
|
|
def self.accept_reviewer
|
2021-07-22 08:10:04 -04:00
|
|
|
argument :reviewer_username, GraphQL::Types::String,
|
2021-03-23 23:09:04 -04:00
|
|
|
required: false,
|
|
|
|
description: 'Username of the reviewer.'
|
2020-12-10 07:09:43 -05:00
|
|
|
end
|
|
|
|
|
2021-07-22 08:10:04 -04:00
|
|
|
argument :iids, [GraphQL::Types::String],
|
2021-03-23 23:09:04 -04:00
|
|
|
required: false,
|
|
|
|
description: 'Array of IIDs of merge requests, for example `[1, 2]`.'
|
2019-01-30 14:00:30 -05:00
|
|
|
|
2021-07-22 08:10:04 -04:00
|
|
|
argument :source_branches, [GraphQL::Types::String],
|
2020-05-21 20:08:07 -04:00
|
|
|
required: false,
|
|
|
|
as: :source_branch,
|
2021-03-23 23:09:04 -04:00
|
|
|
description: <<~DESC
|
|
|
|
Array of source branch names.
|
|
|
|
All resolved merge requests will have one of these branches as their source.
|
|
|
|
DESC
|
2018-06-14 09:06:53 -04:00
|
|
|
|
2021-07-22 08:10:04 -04:00
|
|
|
argument :target_branches, [GraphQL::Types::String],
|
2020-05-21 20:08:07 -04:00
|
|
|
required: false,
|
|
|
|
as: :target_branch,
|
2021-03-23 23:09:04 -04:00
|
|
|
description: <<~DESC
|
|
|
|
Array of target branch names.
|
|
|
|
All resolved merge requests will have one of these branches as their target.
|
|
|
|
DESC
|
2018-05-23 03:55:14 -04:00
|
|
|
|
2020-05-21 20:08:07 -04:00
|
|
|
argument :state, ::Types::MergeRequestStateEnum,
|
|
|
|
required: false,
|
2021-08-19 14:10:32 -04:00
|
|
|
description: 'Merge request state. If provided, all resolved merge requests will have this state.'
|
2019-01-30 14:00:30 -05:00
|
|
|
|
2022-01-17 07:17:11 -05:00
|
|
|
argument :draft, GraphQL::Types::Boolean,
|
|
|
|
required: false,
|
|
|
|
description: 'Limit result to draft merge requests.'
|
|
|
|
|
2022-01-24 10:11:33 -05:00
|
|
|
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.'
|
|
|
|
|
2021-07-22 08:10:04 -04:00
|
|
|
argument :labels, [GraphQL::Types::String],
|
2020-05-21 20:08:07 -04:00
|
|
|
required: false,
|
|
|
|
as: :label_name,
|
|
|
|
description: 'Array of label names. All resolved merge requests will have all of these labels.'
|
2020-08-06 14:09:41 -04:00
|
|
|
argument :merged_after, Types::TimeType,
|
2020-08-28 02:10:45 -04:00
|
|
|
required: false,
|
2021-01-11 19:10:42 -05:00
|
|
|
description: 'Merge requests merged after this date.'
|
2020-08-06 14:09:41 -04:00
|
|
|
argument :merged_before, Types::TimeType,
|
2020-08-28 02:10:45 -04:00
|
|
|
required: false,
|
2021-01-11 19:10:42 -05:00
|
|
|
description: 'Merge requests merged before this date.'
|
2021-07-22 08:10:04 -04:00
|
|
|
argument :milestone_title, GraphQL::Types::String,
|
2020-08-28 02:10:45 -04:00
|
|
|
required: false,
|
2021-01-11 19:10:42 -05:00
|
|
|
description: 'Title of the milestone.'
|
2020-09-02 05:10:23 -04:00
|
|
|
argument :sort, Types::MergeRequestSortEnum,
|
2021-01-11 19:10:42 -05:00
|
|
|
description: 'Sort merge requests by this criteria.',
|
2020-09-02 05:10:23 -04:00
|
|
|
required: false,
|
2020-12-01 22:09:38 -05:00
|
|
|
default_value: :created_desc
|
2020-04-14 05:09:34 -04:00
|
|
|
|
2021-04-07 14:09:45 -04:00
|
|
|
negated do
|
2021-07-22 08:10:04 -04:00
|
|
|
argument :labels, [GraphQL::Types::String],
|
2021-04-07 14:09:45 -04:00
|
|
|
required: false,
|
|
|
|
as: :label_name,
|
|
|
|
description: 'Array of label names. All resolved merge requests will not have these labels.'
|
2021-07-22 08:10:04 -04:00
|
|
|
argument :milestone_title, GraphQL::Types::String,
|
2021-04-07 14:09:45 -04:00
|
|
|
required: false,
|
|
|
|
description: 'Title of the milestone.'
|
|
|
|
end
|
|
|
|
|
2020-05-21 20:08:07 -04:00
|
|
|
def self.single
|
|
|
|
::Resolvers::MergeRequestResolver
|
2020-04-14 05:09:34 -04:00
|
|
|
end
|
|
|
|
|
2020-05-21 20:08:07 -04:00
|
|
|
def no_results_possible?(args)
|
2020-06-02 11:08:24 -04:00
|
|
|
project.nil? || some_argument_is_empty?(args)
|
|
|
|
end
|
|
|
|
|
|
|
|
def some_argument_is_empty?(args)
|
|
|
|
args.values.any? { |v| v.is_a?(Array) && v.empty? }
|
2018-05-23 03:55:14 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|