Commit 513b184b authored by Jan Provaznik's avatar Jan Provaznik

Merge branch '280781-support-assignee-wildcard-filters-board-issues-graphql' into 'master'

Support filtering by assignee wildcard in GraphQL

See merge request gitlab-org/gitlab!58996
parents 1f721e91 57ad690e
......@@ -18,6 +18,17 @@ module BoardIssueFilterable
end
def set_filter_values(filters)
filter_by_assignee(filters)
end
def filter_by_assignee(filters)
if filters[:assignee_username] && filters[:assignee_wildcard_id]
raise ::Gitlab::Graphql::Errors::ArgumentError, 'Incompatible arguments: assigneeUsername, assigneeWildcardId.'
end
if filters[:assignee_wildcard_id]
filters[:assignee_id] = filters.delete(:assignee_wildcard_id)
end
end
end
......
# frozen_string_literal: true
module Types
module Boards
class AssigneeWildcardIdEnum < BaseEnum
graphql_name 'AssigneeWildcardId'
description 'Assignee ID wildcard values'
value 'NONE', 'No assignee is assigned.'
value 'ANY', 'An assignee is assigned.'
end
end
end
......@@ -18,6 +18,10 @@ module Types
argument :search, GraphQL::STRING_TYPE,
required: false,
description: 'Search query for issue title or description.'
argument :assignee_wildcard_id, ::Types::Boards::AssigneeWildcardIdEnum,
required: false,
description: 'Filter by assignee wildcard. Incompatible with assigneeUsername.'
end
end
end
......
---
title: Support filtering by assignee wildcard in GraphQL board list issues query
merge_request: 58996
author:
type: added
......@@ -7525,6 +7525,15 @@ The kind of an approval rule.
| `REGULAR` | A `regular` approval rule. |
| `REPORT_APPROVER` | A `report_approver` approval rule. |
### `AssigneeWildcardId`
Assignee ID wildcard values.
| Value | Description |
| ----- | ----------- |
| `ANY` | An assignee is assigned. |
| `NONE` | No assignee is assigned. |
### `AvailabilityEnum`
User availability status.
......
......@@ -10,6 +10,8 @@ module EE
def set_filter_values(filters)
filter_by_epic(filters)
filter_by_iteration(filters)
super
end
private
......
......@@ -39,6 +39,24 @@ RSpec.describe Resolvers::BoardListIssuesResolver do
expect(result).to match_array([issue1])
end
it 'raises an exception if both assignee_username and assignee_wildcard_id are present' do
expect do
resolve_board_list_issues(args: { filters: { assignee_username: ['username'], assignee_wildcard_id: 'NONE' } })
end.to raise_error(Gitlab::Graphql::Errors::ArgumentError)
end
it 'accepts assignee wildcard id NONE' do
result = resolve_board_list_issues(args: { filters: { assignee_wildcard_id: 'NONE' } })
expect(result).to match_array([issue1, issue2, issue3])
end
it 'accepts assignee wildcard id ANY' do
result = resolve_board_list_issues(args: { filters: { assignee_wildcard_id: 'ANY' } })
expect(result).to match_array([])
end
end
end
......
......@@ -5,9 +5,9 @@ require 'spec_helper'
RSpec.describe GitlabSchema.types['BoardIssueInput'] do
it { expect(described_class.graphql_name).to eq('BoardIssueInput') }
it 'exposes negated issue arguments' do
it 'has specific fields' do
allowed_args = %w(labelName milestoneTitle assigneeUsername authorUsername
releaseTag myReactionEmoji not search)
releaseTag myReactionEmoji not search assigneeWildcardId)
expect(described_class.arguments.keys).to include(*allowed_args)
expect(described_class.arguments['not'].type).to eq(Types::Boards::NegatedBoardIssueInputType)
......
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