Class: Types::BoardListType

Inherits:
BaseObject
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/graphql/types/board_list_type.rb

Overview

rubocop: disable Graphql/AuthorizeTypes

Instance Method Summary collapse

Methods inherited from BaseObject

accepts, assignable?, authorization, authorize, authorized?, #current_user, #id

Methods included from Gitlab::Graphql::Present

#present, #unpresented

Instance Method Details

#collapsedObject



41
42
43
# File 'app/graphql/types/board_list_type.rb', line 41

def collapsed
  object.collapsed?(context[:current_user])
end

#issues_countObject



37
38
39
# File 'app/graphql/types/board_list_type.rb', line 37

def issues_count
  [:size]
end

#metadataObject



45
46
47
48
49
50
51
52
53
# File 'app/graphql/types/board_list_type.rb', line 45

def 
  strong_memoize(:metadata) do
    params = (context[:issue_filters] || {}).merge(board_id: list.board_id, id: list.id)

    ::Boards::Issues::ListService
      .new(list.board.resource_parent, current_user, params)
      .
  end
end

#titleObject

board lists have a data dependency on label - so we batch load them here



56
57
58
59
60
61
62
63
# File 'app/graphql/types/board_list_type.rb', line 56

def title
  BatchLoader::GraphQL.for(object).batch do |lists, callback|
    ActiveRecord::Associations::Preloader.new(records: lists, associations: :label).call # rubocop: disable CodeReuse/ActiveRecord

    # all list titles are preloaded at this point
    lists.each { |list| callback.call(list, list.title) }
  end
end