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