2018-11-27 15:10:40 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Resolvers
|
|
|
|
class IssuesResolver < BaseResolver
|
2019-06-03 18:15:04 +00:00
|
|
|
argument :iid, GraphQL::STRING_TYPE,
|
2019-02-12 16:31:18 +00:00
|
|
|
required: false,
|
|
|
|
description: 'The IID of the issue, e.g., "1"'
|
2018-11-27 15:10:40 +00:00
|
|
|
|
2019-06-03 18:15:04 +00:00
|
|
|
argument :iids, [GraphQL::STRING_TYPE],
|
2019-01-30 17:18:18 +00:00
|
|
|
required: false,
|
|
|
|
description: 'The list of IIDs of issues, e.g., [1, 2]'
|
2019-01-17 17:49:24 +00:00
|
|
|
argument :state, Types::IssuableStateEnum,
|
|
|
|
required: false,
|
|
|
|
description: "Current state of Issue"
|
|
|
|
argument :label_name, GraphQL::STRING_TYPE.to_list_type,
|
|
|
|
required: false,
|
|
|
|
description: "Labels applied to the Issue"
|
|
|
|
argument :created_before, Types::TimeType,
|
|
|
|
required: false,
|
|
|
|
description: "Issues created before this date"
|
|
|
|
argument :created_after, Types::TimeType,
|
|
|
|
required: false,
|
|
|
|
description: "Issues created after this date"
|
|
|
|
argument :updated_before, Types::TimeType,
|
|
|
|
required: false,
|
|
|
|
description: "Issues updated before this date"
|
|
|
|
argument :updated_after, Types::TimeType,
|
|
|
|
required: false,
|
|
|
|
description: "Issues updated after this date"
|
|
|
|
argument :closed_before, Types::TimeType,
|
|
|
|
required: false,
|
|
|
|
description: "Issues closed before this date"
|
|
|
|
argument :closed_after, Types::TimeType,
|
|
|
|
required: false,
|
|
|
|
description: "Issues closed after this date"
|
2018-11-27 15:10:40 +00:00
|
|
|
argument :search, GraphQL::STRING_TYPE,
|
|
|
|
required: false
|
|
|
|
argument :sort, Types::Sort,
|
|
|
|
required: false,
|
|
|
|
default_value: 'created_desc'
|
|
|
|
|
|
|
|
type Types::IssueType, null: true
|
|
|
|
|
|
|
|
alias_method :project, :object
|
|
|
|
|
|
|
|
def resolve(**args)
|
2019-04-22 16:07:19 +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
|
2019-05-20 14:11:44 +00:00
|
|
|
# make sure it's loaded and not `nil` before continuing.
|
2019-04-22 16:07:19 +00:00
|
|
|
project.sync if project.respond_to?(:sync)
|
|
|
|
return Issue.none if project.nil?
|
|
|
|
|
2018-11-27 15:10:40 +00:00
|
|
|
# Will need to be be made group & namespace aware with
|
|
|
|
# https://gitlab.com/gitlab-org/gitlab-ce/issues/54520
|
|
|
|
args[:project_id] = project.id
|
2019-02-12 16:31:18 +00:00
|
|
|
args[:iids] ||= [args[:iid]].compact
|
2018-11-27 15:10:40 +00:00
|
|
|
|
|
|
|
IssuesFinder.new(context[:current_user], args).execute
|
|
|
|
end
|
2019-05-06 21:24:19 +00:00
|
|
|
|
2019-05-31 16:46:16 +00:00
|
|
|
def self.resolver_complexity(args, child_complexity:)
|
2019-05-06 21:24:19 +00:00
|
|
|
complexity = super
|
|
|
|
complexity += 2 if args[:labelName]
|
|
|
|
|
|
|
|
complexity
|
|
|
|
end
|
2018-11-27 15:10:40 +00:00
|
|
|
end
|
|
|
|
end
|