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

68 lines
2.5 KiB
Ruby
Raw Normal View History

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,
description: 'The IID of the issue, e.g., "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,
description: 'The list of IIDs of issues, e.g., [1, 2]'
2019-07-07 11:18:12 +05:30
argument :state, Types::IssuableStateEnum,
required: false,
2019-12-04 20:38:33 +05:30
description: 'Current state of Issue'
2019-07-07 11:18:12 +05:30
argument :label_name, GraphQL::STRING_TYPE.to_list_type,
required: false,
2019-12-04 20:38:33 +05:30
description: 'Labels applied to the 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'
argument :search, GraphQL::STRING_TYPE, # rubocop:disable Graphql/Descriptions
2019-02-15 15:39:39 +05:30
required: false
2019-12-04 20:38:33 +05:30
argument :sort, Types::SortEnum,
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
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