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

40 lines
1.3 KiB
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
module Resolvers
class IssuesResolver < BaseResolver
2020-10-24 23:57:45 +05:30
prepend IssueResolverFields
2019-02-15 15:39:39 +05:30
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-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
2020-05-24 23:13:21 +05:30
NON_STABLE_CURSOR_SORTS = %i[priority_asc priority_desc
label_priority_asc label_priority_desc
milestone_due_asc milestone_due_desc].freeze
2020-10-24 23:57:45 +05:30
def continue_issue_resolve(parent, finder, **args)
2020-07-28 23:09:34 +05:30
issues = Gitlab::Graphql::Loaders::IssuableLoader.new(parent, finder).batching_find_all
2020-05-24 23:13:21 +05:30
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.
Gitlab::Graphql::Pagination::OffsetActiveRecordRelationConnection.new(issues)
else
issues
end
2019-02-15 15:39:39 +05:30
end
2019-07-31 22:56:46 +05:30
2020-05-24 23:13:21 +05:30
def non_stable_cursor_sort?(sort)
NON_STABLE_CURSOR_SORTS.include?(sort)
end
2019-02-15 15:39:39 +05:30
end
end
2020-07-28 23:09:34 +05:30
Resolvers::IssuesResolver.prepend_if_ee('::EE::Resolvers::IssuesResolver')