2018-11-27 10:10:40 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Resolvers
|
|
|
|
class IssuesResolver < BaseResolver
|
2020-09-18 08:09:50 -04:00
|
|
|
prepend IssueResolverArguments
|
2018-11-27 10:10:40 -05:00
|
|
|
|
2019-01-17 12:49:24 -05:00
|
|
|
argument :state, Types::IssuableStateEnum,
|
|
|
|
required: false,
|
2021-01-11 19:10:42 -05:00
|
|
|
description: 'Current state of this issue.'
|
2019-10-04 11:06:38 -04:00
|
|
|
argument :sort, Types::IssueSortEnum,
|
2021-01-11 19:10:42 -05:00
|
|
|
description: 'Sort issues by this criteria.',
|
2018-11-27 10:10:40 -05:00
|
|
|
required: false,
|
2020-12-01 22:09:38 -05:00
|
|
|
default_value: :created_desc
|
2018-11-27 10:10:40 -05:00
|
|
|
|
2020-11-09 19:08:52 -05:00
|
|
|
type Types::IssueType.connection_type, null: true
|
2018-11-27 10:10:40 -05:00
|
|
|
|
2020-05-04 20:10:39 -04:00
|
|
|
NON_STABLE_CURSOR_SORTS = %i[priority_asc priority_desc
|
|
|
|
label_priority_asc label_priority_desc
|
|
|
|
milestone_due_asc milestone_due_desc].freeze
|
2020-04-23 11:09:55 -04:00
|
|
|
|
2020-08-11 23:10:17 -04:00
|
|
|
def continue_issue_resolve(parent, finder, **args)
|
2020-12-20 22:10:05 -05:00
|
|
|
issues = Gitlab::Graphql::Loaders::IssuableLoader.new(parent, finder).batching_find_all { |q| apply_lookahead(q) }
|
2020-04-23 11:09:55 -04:00
|
|
|
|
|
|
|
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.
|
2020-11-26 10:09:30 -05:00
|
|
|
offset_pagination(issues)
|
2020-04-23 11:09:55 -04:00
|
|
|
else
|
|
|
|
issues
|
|
|
|
end
|
2018-11-27 10:10:40 -05:00
|
|
|
end
|
2019-05-06 17:24:19 -04:00
|
|
|
|
2020-08-25 14:10:49 -04:00
|
|
|
private
|
|
|
|
|
2020-12-20 22:10:05 -05:00
|
|
|
def unconditional_includes
|
|
|
|
[
|
|
|
|
{
|
|
|
|
project: [:project_feature]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2020-08-25 14:10:49 -04:00
|
|
|
def preloads
|
|
|
|
{
|
2020-09-04 05:08:38 -04:00
|
|
|
alert_management_alert: [:alert_management_alert],
|
2020-09-07 20:08:20 -04:00
|
|
|
labels: [:labels],
|
2021-04-12 08:09:15 -04:00
|
|
|
assignees: [:assignees],
|
|
|
|
timelogs: [:timelogs]
|
2020-08-25 14:10:49 -04:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2020-04-23 11:09:55 -04:00
|
|
|
def non_stable_cursor_sort?(sort)
|
|
|
|
NON_STABLE_CURSOR_SORTS.include?(sort)
|
|
|
|
end
|
2018-11-27 10:10:40 -05:00
|
|
|
end
|
|
|
|
end
|
2020-07-16 02:09:33 -04:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
Resolvers::IssuesResolver.prepend_mod_with('Resolvers::IssuesResolver')
|