Commit 2e53e1ff authored by Mario de la Ossa's avatar Mario de la Ossa

Add `include_subgroups` to GraphQL Issues

`include_subgroups` is necessary if we want issues belonging to
subgroups returned in the result.
parent 2d896d3e
# frozen_string_literal: true
module Resolvers
class GroupIssuesResolver < IssuesResolver
argument :include_subgroups, GraphQL::BOOLEAN_TYPE,
required: false,
default_value: false,
description: 'Include issues belonging to subgroups.'
end
end
...@@ -47,7 +47,7 @@ module Types ...@@ -47,7 +47,7 @@ module Types
Types::IssueType.connection_type, Types::IssueType.connection_type,
null: true, null: true,
description: 'Issues of the group', description: 'Issues of the group',
resolver: Resolvers::IssuesResolver resolver: Resolvers::GroupIssuesResolver
field :milestones, Types::MilestoneType.connection_type, null: true, field :milestones, Types::MilestoneType.connection_type, null: true,
description: 'Milestones of the group', description: 'Milestones of the group',
......
---
title: 'GraphQL: Issues - Added ''include_subgroup'' parameter'
merge_request: 39279
author:
type: added
...@@ -5928,6 +5928,11 @@ type Group { ...@@ -5928,6 +5928,11 @@ type Group {
""" """
iids: [String!] iids: [String!]
"""
Include issues belonging to subgroups.
"""
includeSubgroups: Boolean = false
""" """
Iterations applied to the issue Iterations applied to the issue
""" """
......
...@@ -16521,6 +16521,16 @@ ...@@ -16521,6 +16521,16 @@
}, },
"defaultValue": null "defaultValue": null
}, },
{
"name": "includeSubgroups",
"description": "Include issues belonging to subgroups.",
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"defaultValue": "false"
},
{ {
"name": "after", "name": "after",
"description": "Returns the elements in the list that come after the specified cursor.", "description": "Returns the elements in the list that come after the specified cursor.",
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Resolvers::GroupIssuesResolver do
include GraphqlHelpers
let_it_be(:current_user) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
let_it_be(:other_project) { create(:project, group: group) }
let_it_be(:subgroup) { create(:group, parent: group) }
let_it_be(:subproject) { create(:project, group: subgroup) }
let_it_be(:issue1) { create(:incident, project: project, state: :opened, created_at: 3.hours.ago, updated_at: 3.hours.ago) }
let_it_be(:issue2) { create(:issue, project: project, state: :closed, title: 'foo', created_at: 1.hour.ago, updated_at: 1.hour.ago, closed_at: 1.hour.ago) }
let_it_be(:issue3) { create(:issue, project: other_project, state: :closed, title: 'foo', created_at: 1.hour.ago, updated_at: 1.hour.ago, closed_at: 1.hour.ago) }
let_it_be(:issue4) { create(:issue) }
let_it_be(:subissue1) { create(:issue, project: subproject) }
let_it_be(:subissue2) { create(:issue, project: subproject) }
let_it_be(:subissue3) { create(:issue, project: subproject) }
before_all do
group.add_developer(current_user)
subgroup.add_developer(current_user)
end
describe '#resolve' do
it 'finds all group issues' do
result = resolve(described_class, obj: group, ctx: { current_user: current_user })
expect(result).to contain_exactly(issue1, issue2, issue3)
end
it 'finds all group and subgroup issues' do
result = resolve(described_class, obj: group, args: { include_subgroups: true }, ctx: { current_user: current_user })
expect(result).to contain_exactly(issue1, issue2, issue3, subissue1, subissue2, subissue3)
end
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