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

53 lines
1.5 KiB
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
module Resolvers
2023-01-13 00:05:48 +05:30
class IssuesResolver < Issues::BaseResolver
prepend ::Issues::LookAheadPreloads
include ::Issues::SortArguments
2023-03-17 16:20:25 +05:30
NON_FILTER_ARGUMENTS = %i[sort lookahead].freeze
2023-01-13 00:05:48 +05:30
argument :state, Types::IssuableStateEnum,
required: false,
description: 'Current state of this issue.'
# see app/graphql/types/issue_connection.rb
type 'Types::IssueConnection', null: true
2023-03-04 22:38:38 +05:30
before_connection_authorization do |nodes, current_user|
projects = nodes.map(&:project)
::Preloaders::UserMaxAccessLevelInProjectsPreloader.new(projects, current_user).execute
end
2023-03-17 16:20:25 +05:30
def ready?(**args)
unless filter_provided?(args)
raise Gitlab::Graphql::Errors::ArgumentError, _('You must provide at least one filter argument for this query')
end
super
end
2023-01-13 00:05:48 +05:30
def resolve_with_lookahead(**args)
return unless Feature.enabled?(:root_level_issues_query)
issues = apply_lookahead(
IssuesFinder.new(current_user, prepare_finder_params(args)).execute
)
if non_stable_cursor_sort?(args[:sort])
# Certain complex sorts are not supported by the stable cursor pagination yet.
# In these cases, we use offset pagination, so we return the correct connection.
offset_pagination(issues)
else
issues
end
end
2023-03-17 16:20:25 +05:30
private
def filter_provided?(args)
args.except(*NON_FILTER_ARGUMENTS).values.any?(&:present?)
end
2019-02-15 15:39:39 +05:30
end
end