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

70 lines
2.4 KiB
Ruby
Raw Normal View History

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
alias_method :project, :synchronized_object
2019-07-07 11:18:12 +05:30
2021-01-03 14:25:43 +05:30
def self.accept_assignee
argument :assignee_username, GraphQL::STRING_TYPE,
required: false,
description: 'Username of the assignee'
end
def self.accept_author
argument :author_username, GraphQL::STRING_TYPE,
required: false,
description: 'Username of the author'
end
2019-09-04 21:01:54 +05:30
argument :iids, [GraphQL::STRING_TYPE],
2019-07-07 11:18:12 +05:30
required: false,
2020-04-22 19:07:51 +05:30
description: 'Array of IIDs of merge requests, for example `[1, 2]`'
2018-11-08 19:23:39 +05:30
2020-06-23 00:09:42 +05:30
argument :source_branches, [GraphQL::STRING_TYPE],
required: false,
as: :source_branch,
description: 'Array of source branch names. All resolved merge requests will have one of these branches as their source.'
2018-11-08 19:23:39 +05:30
2020-06-23 00:09:42 +05:30
argument :target_branches, [GraphQL::STRING_TYPE],
required: false,
as: :target_branch,
description: 'Array of target branch names. All resolved merge requests will have one of these branches as their target.'
2018-11-08 19:23:39 +05:30
2020-06-23 00:09:42 +05:30
argument :state, ::Types::MergeRequestStateEnum,
required: false,
description: 'A merge request state. If provided, all resolved merge requests will have this state.'
2018-11-08 19:23:39 +05:30
2020-06-23 00:09:42 +05:30
argument :labels, [GraphQL::STRING_TYPE],
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,
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,
description: 'Merge requests merged before this date'
argument :milestone_title, GraphQL::STRING_TYPE,
required: false,
description: 'Title of the milestone'
argument :sort, Types::MergeRequestSortEnum,
description: 'Sort merge requests by this criteria',
required: false,
default_value: 'created_desc'
2019-07-07 11:18:12 +05:30
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