2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Resolvers
|
|
|
|
class IssuesResolver < BaseResolver
|
2019-09-04 21:01:54 +05:30
|
|
|
argument :iid, GraphQL::STRING_TYPE,
|
2019-07-07 11:18:12 +05:30
|
|
|
required: false,
|
2020-01-01 13:55:28 +05:30
|
|
|
description: 'IID of the issue. For example, "1"'
|
2019-02-15 15:39:39 +05:30
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
argument :iids, [GraphQL::STRING_TYPE],
|
2019-03-02 22:35:43 +05:30
|
|
|
required: false,
|
2020-01-01 13:55:28 +05:30
|
|
|
description: 'List of IIDs of issues. For example, [1, 2]'
|
2019-07-07 11:18:12 +05:30
|
|
|
argument :state, Types::IssuableStateEnum,
|
|
|
|
required: false,
|
2020-01-01 13:55:28 +05:30
|
|
|
description: 'Current state of this issue'
|
2019-07-07 11:18:12 +05:30
|
|
|
argument :label_name, GraphQL::STRING_TYPE.to_list_type,
|
|
|
|
required: false,
|
2020-01-01 13:55:28 +05:30
|
|
|
description: 'Labels applied to this issue'
|
2019-07-07 11:18:12 +05:30
|
|
|
argument :created_before, Types::TimeType,
|
|
|
|
required: false,
|
2019-12-04 20:38:33 +05:30
|
|
|
description: 'Issues created before this date'
|
2019-07-07 11:18:12 +05:30
|
|
|
argument :created_after, Types::TimeType,
|
|
|
|
required: false,
|
2019-12-04 20:38:33 +05:30
|
|
|
description: 'Issues created after this date'
|
2019-07-07 11:18:12 +05:30
|
|
|
argument :updated_before, Types::TimeType,
|
|
|
|
required: false,
|
2019-12-04 20:38:33 +05:30
|
|
|
description: 'Issues updated before this date'
|
2019-07-07 11:18:12 +05:30
|
|
|
argument :updated_after, Types::TimeType,
|
|
|
|
required: false,
|
2019-12-04 20:38:33 +05:30
|
|
|
description: 'Issues updated after this date'
|
2019-07-07 11:18:12 +05:30
|
|
|
argument :closed_before, Types::TimeType,
|
|
|
|
required: false,
|
2019-12-04 20:38:33 +05:30
|
|
|
description: 'Issues closed before this date'
|
2019-07-07 11:18:12 +05:30
|
|
|
argument :closed_after, Types::TimeType,
|
|
|
|
required: false,
|
2019-12-04 20:38:33 +05:30
|
|
|
description: 'Issues closed after this date'
|
2020-01-01 13:55:28 +05:30
|
|
|
argument :search, GraphQL::STRING_TYPE,
|
|
|
|
required: false,
|
|
|
|
description: 'Search query for finding issues by title or description'
|
2019-12-21 20:55:43 +05:30
|
|
|
argument :sort, Types::IssueSortEnum,
|
2019-12-04 20:38:33 +05:30
|
|
|
description: 'Sort issues by this criteria',
|
2019-02-15 15:39:39 +05:30
|
|
|
required: false,
|
|
|
|
default_value: 'created_desc'
|
|
|
|
|
|
|
|
type Types::IssueType, null: true
|
|
|
|
|
|
|
|
def resolve(**args)
|
2019-07-31 22:56:46 +05:30
|
|
|
# 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-09-04 21:01:54 +05:30
|
|
|
# make sure it's loaded and not `nil` before continuing.
|
2019-12-04 20:38:33 +05:30
|
|
|
project = object.respond_to?(:sync) ? object.sync : object
|
2019-07-31 22:56:46 +05:30
|
|
|
return Issue.none if project.nil?
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
# Will need to be be made group & namespace aware with
|
2019-12-04 20:38:33 +05:30
|
|
|
# https://gitlab.com/gitlab-org/gitlab-foss/issues/54520
|
2019-02-15 15:39:39 +05:30
|
|
|
args[:project_id] = project.id
|
2019-07-07 11:18:12 +05:30
|
|
|
args[:iids] ||= [args[:iid]].compact
|
2020-01-01 13:55:28 +05:30
|
|
|
args[:attempt_project_search_optimizations] = args[:search].present?
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
IssuesFinder.new(context[:current_user], args).execute
|
|
|
|
end
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
def self.resolver_complexity(args, child_complexity:)
|
2019-07-31 22:56:46 +05:30
|
|
|
complexity = super
|
|
|
|
complexity += 2 if args[:labelName]
|
|
|
|
|
|
|
|
complexity
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
end
|