Commit db4ed7aa authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '229433-graphql-issue-subgroup' into 'master'

Add `include_subgroups` to GraphQL Issues

Closes #229433

See merge request gitlab-org/gitlab!39279
parents 93ef6be6 2e53e1ff
# 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
Types::IssueType.connection_type,
null: true,
description: 'Issues of the group',
resolver: Resolvers::IssuesResolver
resolver: Resolvers::GroupIssuesResolver
field :milestones, Types::MilestoneType.connection_type, null: true,
description: 'Milestones of the group',
......
---
title: 'GraphQL: Issues - Added ''include_subgroup'' parameter'
merge_request: 39279
author:
type: added
......@@ -5988,6 +5988,11 @@ type Group {
"""
iids: [String!]
"""
Include issues belonging to subgroups.
"""
includeSubgroups: Boolean = false
"""
Iterations applied to the issue
"""
......
......@@ -16685,6 +16685,16 @@
},
"defaultValue": null
},
{
"name": "includeSubgroups",
"description": "Include issues belonging to subgroups.",
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"defaultValue": "false"
},
{
"name": "after",
"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