Commit 73540f95 authored by charlieablett's avatar charlieablett Committed by charlie ablett

GraphQL expose issues under board list

- Add test
parent 5f2283ed
# frozen_string_literal: true
module Resolvers
class BoardListIssuesResolver < BaseResolver
type Types::IssueType, null: true
alias_method :list, :object
def resolve(**args)
# rubocop: disable CodeReuse/ActiveRecord
service = Boards::Issues::ListService.new(list.board.resource_parent, context[:current_user], { board_id: list.board.id, id: list.id })
service.execute.reorder("relative_position ASC")
# rubocop: enable CodeReuse/ActiveRecord
end
end
end
......@@ -19,6 +19,10 @@ 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, ::Types::IssueType.connection_type, null: true,
description: 'Board issues',
resolver: ::Resolvers::BoardListIssuesResolver
end
# rubocop: enable Graphql/AuthorizeTypes
end
......
......@@ -1087,6 +1087,31 @@ type BoardList {
"""
id: ID!
"""
Board issues
"""
issues(
"""
Returns the elements in the list that come after the specified cursor.
"""
after: String
"""
Returns the elements in the list that come before the specified cursor.
"""
before: String
"""
Returns the first _n_ elements from the list.
"""
first: Int
"""
Returns the last _n_ elements from the list.
"""
last: Int
): IssueConnection
"""
Label of the list
"""
......
......@@ -2927,6 +2927,59 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "issues",
"description": "Board issues",
"args": [
{
"name": "after",
"description": "Returns the elements in the list that come after the specified cursor.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "before",
"description": "Returns the elements in the list that come before the specified cursor.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
},
{
"name": "first",
"description": "Returns the first _n_ elements from the list.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
},
{
"name": "last",
"description": "Returns the last _n_ elements from the list.",
"type": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
},
"defaultValue": null
}
],
"type": {
"kind": "OBJECT",
"name": "IssueConnection",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "label",
"description": "Label of the list",
......@@ -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]
expected_fields = %w[id list_type position label 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