summaryrefslogtreecommitdiff
path: root/app/graphql/types/board_list_type.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/types/board_list_type.rb')
-rw-r--r--app/graphql/types/board_list_type.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/app/graphql/types/board_list_type.rb b/app/graphql/types/board_list_type.rb
index 762e03973d9..8c67803e39e 100644
--- a/app/graphql/types/board_list_type.rb
+++ b/app/graphql/types/board_list_type.rb
@@ -10,8 +10,10 @@ module Types
alias_method :list, :object
- field :id, GraphQL::Types::ID, null: false,
+ field :id, GraphQL::Types::ID,
+ null: false,
description: 'ID (global ID) of the list.'
+
field :title, GraphQL::Types::String, null: false,
description: 'Title of the list.'
field :list_type, GraphQL::Types::String, null: false,
@@ -27,6 +29,7 @@ module Types
field :issues, ::Types::IssueType.connection_type, null: true,
description: 'Board issues.',
+ late_extensions: [Gitlab::Graphql::Board::IssuesConnectionExtension],
resolver: ::Resolvers::BoardListIssuesResolver
def issues_count
@@ -46,6 +49,16 @@ module Types
.metadata
end
end
+
+ # board lists have a data dependency on label - so we batch load them here
+ def title
+ BatchLoader::GraphQL.for(object).batch do |lists, callback|
+ ActiveRecord::Associations::Preloader.new.preload(lists, :label) # rubocop: disable CodeReuse/ActiveRecord
+
+ # all list titles are preloaded at this point
+ lists.each { |list| callback.call(list, list.title) }
+ end
+ end
end
# rubocop: enable Graphql/AuthorizeTypes
end