Commit 933b0a7d authored by Alex Kalderimis's avatar Alex Kalderimis

Merge branch '354491-graphql-group-issues-non-archived' into 'master'

Filter archived issues / MRs from GraphQL

See merge request gitlab-org/gitlab!82673
parents 44c0456a 0447c882
......@@ -3,12 +3,21 @@
module GroupIssuableResolver
extend ActiveSupport::Concern
class_methods do
def include_subgroups(name_of_things)
argument :include_subgroups, GraphQL::Types::Boolean,
required: false,
default_value: false,
description: "Include #{name_of_things} belonging to subgroups"
end
included do
argument :include_subgroups, GraphQL::Types::Boolean,
required: false,
default_value: false,
description: "Include #{issuable_collection_name} belonging to subgroups"
argument :include_archived, GraphQL::Types::Boolean,
required: false,
default_value: false,
description: "Return #{issuable_collection_name} from archived projects"
end
def resolve(**args)
args[:non_archived] = !args.delete(:include_archived)
super
end
end
......@@ -3,9 +3,11 @@
module Resolvers
class GroupIssuesResolver < BaseIssuesResolver
include GroupIssuableResolver
def self.issuable_collection_name
'issues'
end
include_subgroups 'issues'
include GroupIssuableResolver
def ready?(**args)
if args.dig(:not, :release_tag).present?
......
......@@ -2,13 +2,16 @@
module Resolvers
class GroupMergeRequestsResolver < MergeRequestsResolver
def self.issuable_collection_name
'merge requests'
end
include GroupIssuableResolver
alias_method :group, :object
type Types::MergeRequestType.connection_type, null: true
include_subgroups 'merge requests'
accept_assignee
accept_author
......
......@@ -11473,6 +11473,7 @@ four standard [pagination arguments](#connection-pagination-arguments):
| <a id="groupissuesepicid"></a>`epicId` | [`String`](#string) | ID of an epic associated with the issues, "none" and "any" values are supported. |
| <a id="groupissuesiid"></a>`iid` | [`String`](#string) | IID of the issue. For example, "1". |
| <a id="groupissuesiids"></a>`iids` | [`[String!]`](#string) | List of IIDs of issues. For example, `["1", "2"]`. |
| <a id="groupissuesincludearchived"></a>`includeArchived` | [`Boolean`](#boolean) | Return issues from archived projects. |
| <a id="groupissuesincludesubepics"></a>`includeSubepics` | [`Boolean`](#boolean) | Whether to include subepics when filtering issues by epicId. |
| <a id="groupissuesincludesubgroups"></a>`includeSubgroups` | [`Boolean`](#boolean) | Include issues belonging to subgroups. |
| <a id="groupissuesiterationid"></a>`iterationId` | [`[ID]`](#id) | List of iteration Global IDs applied to the issue. |
......@@ -11606,6 +11607,7 @@ four standard [pagination arguments](#connection-pagination-arguments):
| <a id="groupmergerequestscreatedbefore"></a>`createdBefore` | [`Time`](#time) | Merge requests created before this timestamp. |
| <a id="groupmergerequestsdraft"></a>`draft` | [`Boolean`](#boolean) | Limit result to draft merge requests. |
| <a id="groupmergerequestsiids"></a>`iids` | [`[String!]`](#string) | Array of IIDs of merge requests, for example `[1, 2]`. |
| <a id="groupmergerequestsincludearchived"></a>`includeArchived` | [`Boolean`](#boolean) | Return merge requests from archived projects. |
| <a id="groupmergerequestsincludesubgroups"></a>`includeSubgroups` | [`Boolean`](#boolean) | Include merge requests belonging to subgroups. |
| <a id="groupmergerequestslabels"></a>`labels` | [`[String!]`](#string) | Array of label names. All resolved merge requests will have all of these labels. |
| <a id="groupmergerequestsmergedafter"></a>`mergedAfter` | [`Time`](#time) | Merge requests merged after this date. |
......@@ -44,6 +44,31 @@ RSpec.describe 'getting an issue list for a group' do
end
end
context 'when there are archived projects' do
let_it_be(:archived_project) { create(:project, :archived, group: group1) }
let_it_be(:archived_issue) { create(:issue, project: archived_project) }
before_all do
group1.add_developer(current_user)
end
it 'excludes issues from archived projects by default' do
post_graphql(query, current_user: current_user)
expect(issues_ids).to contain_exactly(issue1_gid, issue2_gid)
end
context 'when include_archived is true' do
let(:issue_filter_params) { { include_archived: true } }
it 'includes issues from archived projects' do
post_graphql(query, current_user: current_user)
expect(issues_ids).to contain_exactly(issue1_gid, issue2_gid, archived_issue.to_global_id.to_s)
end
end
end
context 'when there is a confidential issue' do
let_it_be(:confidential_issue1) { create(:issue, :confidential, project: project1) }
let_it_be(:confidential_issue2) { create(:issue, :confidential, project: project2) }
......
......@@ -16,6 +16,9 @@ RSpec.describe 'Query.group.mergeRequests' do
let_it_be(:project_x) { create(:project, :repository) }
let_it_be(:user) { create(:user, developer_projects: [project_x]) }
let_it_be(:archived_project) { create(:project, :archived, :repository, group: group) }
let_it_be(:archived_mr) { create(:merge_request, source_project: archived_project) }
let_it_be(:mr_attrs) do
{ target_branch: 'master' }
end
......@@ -119,4 +122,22 @@ RSpec.describe 'Query.group.mergeRequests' do
expect(mrs_data).to match_array(expected_mrs(mrs_a + mrs_b + mrs_c))
end
end
describe 'passing include_archived: true' do
let(:query) do
<<~GQL
query($path: ID!) {
group(fullPath: $path) {
mergeRequests(includeArchived: true) { nodes { id } }
}
}
GQL
end
it 'can find all merge requests in the group, including from archived projects' do
post_graphql(query, current_user: user, variables: { path: group.full_path })
expect(mrs_data).to match_array(expected_mrs(mrs_a + mrs_b + [archived_mr]))
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