Commit ad51968c authored by charlie ablett's avatar charlie ablett

Try offset pagination again

parent 693d3c8d
......@@ -7,10 +7,8 @@ module Resolvers
alias_method :list, :object
def resolve(**args)
# rubocop: disable CodeReuse/ActiveRecord
service = Boards::Issues::ListService.new(list.board.resource_parent, context[:current_user], { board_id: list.board.id, id: list.id })
service.execute.reorder("issues.relative_position ASC, issues.id DESC")
# rubocop: enable CodeReuse/ActiveRecord
Gitlab::Graphql::Pagination::OffsetActiveRecordRelationConnection.new(service.execute)
end
end
end
......@@ -7,7 +7,11 @@ module Types
description: 'Total count of collection'
def count
# rubocop: disable CodeReuse/ActiveRecord
relation = object.items
# sometimes relation is an Array
relation = relation.reorder(nil) if relation.respond_to?(:reorder)
# rubocop: enable CodeReuse/ActiveRecord
if relation.try(:group_values)&.present?
relation.size.keys.size
......
......@@ -27,7 +27,7 @@ RSpec.describe Resolvers::BoardListIssuesResolver do
issue3 = create(:issue, project: project, labels: [label], relative_position: 10)
# by relative_position and then ID
issues = resolve_board_list_issues
issues = resolve_board_list_issues.items
expect(issues.map(&:id)).to eq [issue3.id, issue1.id, issue2.id]
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment