Commit bb5f7d52 authored by Jarka Košanová's avatar Jarka Košanová

Add new fields to the board list graphql endpoint

- add total_weight and issues_count
- update documentation
- update specs
parent 5dc74668
......@@ -3,6 +3,8 @@
module Types
# rubocop: disable Graphql/AuthorizeTypes
class BoardListType < BaseObject
include Gitlab::Utils::StrongMemoize
graphql_name 'BoardList'
description 'Represents a list for an issue board'
......@@ -19,10 +21,31 @@ module Types
field :collapsed, GraphQL::BOOLEAN_TYPE, null: true,
description: 'Indicates if list is collapsed for this user',
resolve: -> (list, _args, ctx) { list.collapsed?(ctx[:current_user]) }
field :issues_count, GraphQL::INT_TYPE, null: true,
description: 'Count of issues in the list'
field :issues, ::Types::IssueType.connection_type, null: true,
description: 'Board issues',
resolver: ::Resolvers::BoardListIssuesResolver
def issues_count
metadata[:size]
end
def total_weight
metadata[:total_weight]
end
def metadata
strong_memoize(:metadata) do
list = self.object
user = context[:current_user]
Boards::Issues::ListService
.new(list.board.resource_parent, user, board_id: list.board_id, id: list.id)
.metadata
end
end
end
# rubocop: enable Graphql/AuthorizeTypes
end
......
---
title: Add total_weight and issues_count fields to the board list graphQL endpoint
merge_request: 39110
author:
type: added
......@@ -1224,6 +1224,11 @@ type BoardList {
last: Int
): IssueConnection
"""
Count of issues in the list
"""
issuesCount: Int
"""
Label of the list
"""
......@@ -1263,6 +1268,11 @@ type BoardList {
Title of the list
"""
title: String!
"""
Total weight of all issues in the list
"""
totalWeight: Int
}
"""
......
......@@ -3254,6 +3254,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "issuesCount",
"description": "Count of issues in the list",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "label",
"description": "Label of the list",
......@@ -3373,6 +3387,20 @@
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "totalWeight",
"description": "Total weight of all issues in the list",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
......@@ -207,6 +207,7 @@ Represents a list for an issue board
| `assignee` | User | Assignee in the list |
| `collapsed` | Boolean | Indicates if list is collapsed for this user |
| `id` | ID! | ID (global ID) of the list |
| `issuesCount` | Int | Count of issues in the list |
| `label` | Label | Label of the list |
| `limitMetric` | ListLimitMetric | The current limit metric for the list |
| `listType` | String! | Type of the list |
......@@ -215,6 +216,7 @@ Represents a list for an issue board
| `milestone` | Milestone | Milestone of the list |
| `position` | Int | Position of list within the board |
| `title` | String! | Title of the list |
| `totalWeight` | Int | Total weight of all issues in the list |
## BoardListCreatePayload
......
......@@ -16,6 +16,8 @@ module EE
description: 'Assignee in the list'
field :limit_metric, ::EE::Types::ListLimitMetricEnum, null: true,
description: 'The current limit metric for the list'
field :total_weight, GraphQL::INT_TYPE, null: true,
description: 'Total weight of all issues in the list'
def milestone
::Gitlab::Graphql::Loaders::BatchModelLoader.new(::Milestone, object.milestone_id).find
......
......@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe GitlabSchema.types['BoardList'] do
it 'has specific fields' do
expected_fields = %w[milestone max_issue_count max_issue_weight assignee]
expected_fields = %w[milestone max_issue_count max_issue_weight assignee total_weight]
expect(described_class).to include_graphql_fields(*expected_fields)
end
......
......@@ -6,7 +6,7 @@ RSpec.describe GitlabSchema.types['BoardList'] do
specify { expect(described_class.graphql_name).to eq('BoardList') }
it 'has specific fields' do
expected_fields = %w[id list_type position label issues]
expected_fields = %w[id list_type position label issues_count issues]
expect(described_class).to include_graphql_fields(*expected_fields)
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