Commit f5bb7cef authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch '235106-board-list-graphql' into 'master'

Add new fields to the board list graphql endpoint

See merge request gitlab-org/gitlab!39110
parents 875646b6 bb5f7d52
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
module Types module Types
# rubocop: disable Graphql/AuthorizeTypes # rubocop: disable Graphql/AuthorizeTypes
class BoardListType < BaseObject class BoardListType < BaseObject
include Gitlab::Utils::StrongMemoize
graphql_name 'BoardList' graphql_name 'BoardList'
description 'Represents a list for an issue board' description 'Represents a list for an issue board'
...@@ -19,10 +21,31 @@ module Types ...@@ -19,10 +21,31 @@ module Types
field :collapsed, GraphQL::BOOLEAN_TYPE, null: true, field :collapsed, GraphQL::BOOLEAN_TYPE, null: true,
description: 'Indicates if list is collapsed for this user', description: 'Indicates if list is collapsed for this user',
resolve: -> (list, _args, ctx) { list.collapsed?(ctx[:current_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, field :issues, ::Types::IssueType.connection_type, null: true,
description: 'Board issues', description: 'Board issues',
resolver: ::Resolvers::BoardListIssuesResolver 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 end
# rubocop: enable Graphql/AuthorizeTypes # rubocop: enable Graphql/AuthorizeTypes
end 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 { ...@@ -1224,6 +1224,11 @@ type BoardList {
last: Int last: Int
): IssueConnection ): IssueConnection
"""
Count of issues in the list
"""
issuesCount: Int
""" """
Label of the list Label of the list
""" """
...@@ -1263,6 +1268,11 @@ type BoardList { ...@@ -1263,6 +1268,11 @@ type BoardList {
Title of the list Title of the list
""" """
title: String! title: String!
"""
Total weight of all issues in the list
"""
totalWeight: Int
} }
""" """
......
...@@ -3254,6 +3254,20 @@ ...@@ -3254,6 +3254,20 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "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", "name": "label",
"description": "Label of the list", "description": "Label of the list",
...@@ -3373,6 +3387,20 @@ ...@@ -3373,6 +3387,20 @@
}, },
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "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, "inputFields": null,
...@@ -207,6 +207,7 @@ Represents a list for an issue board ...@@ -207,6 +207,7 @@ Represents a list for an issue board
| `assignee` | User | Assignee in the list | | `assignee` | User | Assignee in the list |
| `collapsed` | Boolean | Indicates if list is collapsed for this user | | `collapsed` | Boolean | Indicates if list is collapsed for this user |
| `id` | ID! | ID (global ID) of the list | | `id` | ID! | ID (global ID) of the list |
| `issuesCount` | Int | Count of issues in the list |
| `label` | Label | Label of the list | | `label` | Label | Label of the list |
| `limitMetric` | ListLimitMetric | The current limit metric for the list | | `limitMetric` | ListLimitMetric | The current limit metric for the list |
| `listType` | String! | Type of the list | | `listType` | String! | Type of the list |
...@@ -215,6 +216,7 @@ Represents a list for an issue board ...@@ -215,6 +216,7 @@ Represents a list for an issue board
| `milestone` | Milestone | Milestone of the list | | `milestone` | Milestone | Milestone of the list |
| `position` | Int | Position of list within the board | | `position` | Int | Position of list within the board |
| `title` | String! | Title of the list | | `title` | String! | Title of the list |
| `totalWeight` | Int | Total weight of all issues in the list |
## BoardListCreatePayload ## BoardListCreatePayload
......
...@@ -16,6 +16,8 @@ module EE ...@@ -16,6 +16,8 @@ module EE
description: 'Assignee in the list' description: 'Assignee in the list'
field :limit_metric, ::EE::Types::ListLimitMetricEnum, null: true, field :limit_metric, ::EE::Types::ListLimitMetricEnum, null: true,
description: 'The current limit metric for the list' 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 def milestone
::Gitlab::Graphql::Loaders::BatchModelLoader.new(::Milestone, object.milestone_id).find ::Gitlab::Graphql::Loaders::BatchModelLoader.new(::Milestone, object.milestone_id).find
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe GitlabSchema.types['BoardList'] do RSpec.describe GitlabSchema.types['BoardList'] do
it 'has specific fields' 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) expect(described_class).to include_graphql_fields(*expected_fields)
end end
......
...@@ -6,7 +6,7 @@ RSpec.describe GitlabSchema.types['BoardList'] do ...@@ -6,7 +6,7 @@ RSpec.describe GitlabSchema.types['BoardList'] do
specify { expect(described_class.graphql_name).to eq('BoardList') } specify { expect(described_class.graphql_name).to eq('BoardList') }
it 'has specific fields' do 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) expect(described_class).to include_graphql_fields(*expected_fields)
end 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