blob: b1d43934f24983674b7ede2d717ecadf54ead2f3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# frozen_string_literal: true
module Resolvers
class BoardListsResolver < BaseResolver
include Gitlab::Graphql::Authorize::AuthorizeResource
type Types::BoardListType, null: true
argument :id, GraphQL::ID_TYPE,
required: false,
description: 'Find a list by its global ID'
alias_method :board, :object
def resolve(lookahead: nil, id: nil)
authorize!(board)
lists = board_lists(id)
if load_preferences?(lookahead)
List.preload_preferences_for_user(lists, context[:current_user])
end
Gitlab::Graphql::Pagination::OffsetActiveRecordRelationConnection.new(lists)
end
private
def board_lists(id)
service = Boards::Lists::ListService.new(
board.resource_parent,
context[:current_user],
list_id: extract_list_id(id)
)
service.execute(board, create_default_lists: false)
end
def authorized_resource?(board)
Ability.allowed?(context[:current_user], :read_list, board)
end
def load_preferences?(lookahead)
lookahead&.selection(:edges)&.selection(:node)&.selects?(:collapsed)
end
def extract_list_id(gid)
return unless gid.present?
GitlabSchema.parse_gid(gid, expected_type: ::List).model_id
end
end
end
|