2020-08-12 03:10:17 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-09-18 12:09:50 +00:00
|
|
|
module IssueResolverArguments
|
2020-08-12 03:10:17 +00:00
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
prepended do
|
2021-09-21 15:12:11 +00:00
|
|
|
include SearchArguments
|
2020-08-25 18:10:49 +00:00
|
|
|
include LooksAhead
|
|
|
|
|
2021-07-22 12:10:04 +00:00
|
|
|
argument :iid, GraphQL::Types::String,
|
2021-04-22 12:09:49 +00:00
|
|
|
required: false,
|
|
|
|
description: 'IID of the issue. For example, "1".'
|
2021-07-22 12:10:04 +00:00
|
|
|
argument :iids, [GraphQL::Types::String],
|
2021-04-22 12:09:49 +00:00
|
|
|
required: false,
|
2021-06-18 21:10:06 +00:00
|
|
|
description: 'List of IIDs of issues. For example, `["1", "2"]`.'
|
2021-07-22 12:10:04 +00:00
|
|
|
argument :label_name, [GraphQL::Types::String, null: true],
|
2021-04-22 12:09:49 +00:00
|
|
|
required: false,
|
|
|
|
description: 'Labels applied to this issue.'
|
2021-07-22 12:10:04 +00:00
|
|
|
argument :milestone_title, [GraphQL::Types::String, null: true],
|
2021-04-22 12:09:49 +00:00
|
|
|
required: false,
|
|
|
|
description: 'Milestone applied to this issue.'
|
2021-07-22 12:10:04 +00:00
|
|
|
argument :author_username, GraphQL::Types::String,
|
2021-04-22 12:09:49 +00:00
|
|
|
required: false,
|
|
|
|
description: 'Username of the author of the issue.'
|
2021-07-22 12:10:04 +00:00
|
|
|
argument :assignee_username, GraphQL::Types::String,
|
2021-04-22 12:09:49 +00:00
|
|
|
required: false,
|
|
|
|
description: 'Username of a user assigned to the issue.',
|
|
|
|
deprecated: { reason: 'Use `assigneeUsernames`', milestone: '13.11' }
|
2021-07-22 12:10:04 +00:00
|
|
|
argument :assignee_usernames, [GraphQL::Types::String],
|
2021-04-22 12:09:49 +00:00
|
|
|
required: false,
|
|
|
|
description: 'Usernames of users assigned to the issue.'
|
2021-07-22 12:10:04 +00:00
|
|
|
argument :assignee_id, GraphQL::Types::String,
|
2021-04-22 12:09:49 +00:00
|
|
|
required: false,
|
2021-09-07 09:11:43 +00:00
|
|
|
description: 'ID of a user assigned to the issues. Wildcard values "NONE" and "ANY" are supported.'
|
2020-08-12 03:10:17 +00:00
|
|
|
argument :created_before, Types::TimeType,
|
2021-04-22 12:09:49 +00:00
|
|
|
required: false,
|
|
|
|
description: 'Issues created before this date.'
|
2020-08-12 03:10:17 +00:00
|
|
|
argument :created_after, Types::TimeType,
|
2021-04-22 12:09:49 +00:00
|
|
|
required: false,
|
|
|
|
description: 'Issues created after this date.'
|
2020-08-12 03:10:17 +00:00
|
|
|
argument :updated_before, Types::TimeType,
|
2021-04-22 12:09:49 +00:00
|
|
|
required: false,
|
|
|
|
description: 'Issues updated before this date.'
|
2020-08-12 03:10:17 +00:00
|
|
|
argument :updated_after, Types::TimeType,
|
2021-04-22 12:09:49 +00:00
|
|
|
required: false,
|
|
|
|
description: 'Issues updated after this date.'
|
2020-08-12 03:10:17 +00:00
|
|
|
argument :closed_before, Types::TimeType,
|
2021-04-22 12:09:49 +00:00
|
|
|
required: false,
|
|
|
|
description: 'Issues closed before this date.'
|
2020-08-12 03:10:17 +00:00
|
|
|
argument :closed_after, Types::TimeType,
|
2021-04-22 12:09:49 +00:00
|
|
|
required: false,
|
|
|
|
description: 'Issues closed after this date.'
|
2020-08-12 03:10:17 +00:00
|
|
|
argument :types, [Types::IssueTypeEnum],
|
2021-04-22 12:09:49 +00:00
|
|
|
as: :issue_types,
|
|
|
|
description: 'Filter issues by the given issue types.',
|
|
|
|
required: false
|
2021-07-29 09:08:46 +00:00
|
|
|
argument :milestone_wildcard_id, ::Types::MilestoneWildcardIdEnum,
|
|
|
|
required: false,
|
|
|
|
description: 'Filter issues by milestone ID wildcard.'
|
2021-09-07 09:11:43 +00:00
|
|
|
argument :my_reaction_emoji, GraphQL::Types::String,
|
|
|
|
required: false,
|
|
|
|
description: 'Filter by reaction emoji applied by the current user. Wildcard values "NONE" and "ANY" are supported.'
|
2021-10-04 18:12:46 +00:00
|
|
|
argument :confidential,
|
|
|
|
GraphQL::Types::Boolean,
|
|
|
|
required: false,
|
|
|
|
description: 'Filter for confidential issues. If "false", excludes confidential issues. If "true", returns only confidential issues.'
|
2021-04-14 15:09:04 +00:00
|
|
|
argument :not, Types::Issues::NegatedIssueFilterInputType,
|
2021-04-22 12:09:49 +00:00
|
|
|
description: 'Negated arguments.',
|
2021-04-14 15:09:04 +00:00
|
|
|
prepare: ->(negated_args, ctx) { negated_args.to_h },
|
|
|
|
required: false
|
2020-08-12 03:10:17 +00:00
|
|
|
end
|
|
|
|
|
2020-08-25 18:10:49 +00:00
|
|
|
def resolve_with_lookahead(**args)
|
2020-08-12 03:10:17 +00:00
|
|
|
# The project could have been loaded in batch by `BatchLoader`.
|
|
|
|
# At this point we need the `id` of the project to query for issues, so
|
|
|
|
# make sure it's loaded and not `nil` before continuing.
|
|
|
|
parent = object.respond_to?(:sync) ? object.sync : object
|
|
|
|
return Issue.none if parent.nil?
|
|
|
|
|
|
|
|
# Will need to be made group & namespace aware with
|
|
|
|
# https://gitlab.com/gitlab-org/gitlab-foss/issues/54520
|
|
|
|
args[:iids] ||= [args.delete(:iid)].compact if args[:iid]
|
|
|
|
args[:attempt_project_search_optimizations] = true if args[:search].present?
|
|
|
|
|
2021-04-14 15:09:04 +00:00
|
|
|
prepare_assignee_username_params(args)
|
|
|
|
|
2020-08-12 03:10:17 +00:00
|
|
|
finder = IssuesFinder.new(current_user, args)
|
|
|
|
|
|
|
|
continue_issue_resolve(parent, finder, **args)
|
|
|
|
end
|
|
|
|
|
2021-04-14 15:09:04 +00:00
|
|
|
def ready?(**args)
|
2021-07-29 09:08:46 +00:00
|
|
|
params_not_mutually_exclusive(args, mutually_exclusive_assignee_username_args)
|
|
|
|
params_not_mutually_exclusive(args, mutually_exclusive_milestone_args)
|
|
|
|
params_not_mutually_exclusive(args.fetch(:not, {}), mutually_exclusive_milestone_args)
|
2021-09-21 15:12:11 +00:00
|
|
|
validate_anonymous_search_access! if args[:search].present?
|
2021-04-14 15:09:04 +00:00
|
|
|
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
2020-08-12 03:10:17 +00:00
|
|
|
class_methods do
|
|
|
|
def resolver_complexity(args, child_complexity:)
|
|
|
|
complexity = super
|
|
|
|
complexity += 2 if args[:labelName]
|
|
|
|
|
|
|
|
complexity
|
|
|
|
end
|
|
|
|
end
|
2021-04-14 15:09:04 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def prepare_assignee_username_params(args)
|
|
|
|
args[:assignee_username] = args.delete(:assignee_usernames) if args[:assignee_usernames].present?
|
|
|
|
args[:not][:assignee_username] = args[:not].delete(:assignee_usernames) if args.dig(:not, :assignee_usernames).present?
|
|
|
|
end
|
|
|
|
|
2021-07-29 09:08:46 +00:00
|
|
|
def params_not_mutually_exclusive(args, mutually_exclusive_args)
|
|
|
|
if args.slice(*mutually_exclusive_args).compact.size > 1
|
|
|
|
arg_str = mutually_exclusive_args.map { |x| x.to_s.camelize(:lower) }.join(', ')
|
|
|
|
raise ::Gitlab::Graphql::Errors::ArgumentError, "only one of [#{arg_str}] arguments is allowed at the same time."
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def mutually_exclusive_milestone_args
|
|
|
|
[:milestone_title, :milestone_wildcard_id]
|
|
|
|
end
|
|
|
|
|
2021-04-14 15:09:04 +00:00
|
|
|
def mutually_exclusive_assignee_username_args
|
|
|
|
[:assignee_usernames, :assignee_username]
|
|
|
|
end
|
2020-08-12 03:10:17 +00:00
|
|
|
end
|