Commit c85aa31d authored by Alex Pooley's avatar Alex Pooley

Merge branch '353632-filter-taskable-work-item-types' into 'master'

Add taskable filter to work item type resolver

See merge request gitlab-org/gitlab!82137
parents 7aca51cc 38450470
......@@ -5,12 +5,20 @@ module Resolvers
class TypesResolver < BaseResolver
type Types::WorkItems::TypeType.connection_type, null: true
def resolve
argument :taskable, ::GraphQL::Types::Boolean,
required: false,
description: 'If `true`, only taskable work item types will be returned.' \
' Argument is experimental and can be removed in the future without notice.'
def resolve(taskable: nil)
return unless Feature.enabled?(:work_items, object)
# This will require a finder in the future when groups/projects get their work item types
# All groups/projects use the default types for now
::WorkItems::Type.default.order_by_name_asc
base_scope = ::WorkItems::Type.default
base_scope = base_scope.by_type(:task) if taskable
base_scope.order_by_name_asc
end
end
end
......
......@@ -38,6 +38,7 @@ module WorkItems
scope :default, -> { where(namespace: nil) }
scope :order_by_name_asc, -> { order('LOWER(name)') }
scope :by_type, ->(base_type) { where(base_type: base_type) }
def self.default_by_type(type)
find_by(namespace_id: nil, base_type: type)
......
......@@ -11148,7 +11148,6 @@ four standard [pagination arguments](#connection-pagination-arguments):
| <a id="groupvisibility"></a>`visibility` | [`String`](#string) | Visibility of the namespace. |
| <a id="groupvulnerabilityscanners"></a>`vulnerabilityScanners` | [`VulnerabilityScannerConnection`](#vulnerabilityscannerconnection) | Vulnerability scanners reported on the project vulnerabilities of the group and its subgroups. (see [Connections](#connections)) |
| <a id="groupweburl"></a>`webUrl` | [`String!`](#string) | Web URL of the group. |
| <a id="groupworkitemtypes"></a>`workItemTypes` | [`WorkItemTypeConnection`](#workitemtypeconnection) | Work item types available to the group. Returns `null` if `work_items` feature flag is disabled. This flag is disabled by default, because the feature is experimental and is subject to change without notice. (see [Connections](#connections)) |
#### Fields with arguments
......@@ -11705,6 +11704,22 @@ Returns [`VulnerabilitySeveritiesCount`](#vulnerabilityseveritiescount).
| <a id="groupvulnerabilityseveritiescountseverity"></a>`severity` | [`[VulnerabilitySeverity!]`](#vulnerabilityseverity) | Filter vulnerabilities by severity. |
| <a id="groupvulnerabilityseveritiescountstate"></a>`state` | [`[VulnerabilityState!]`](#vulnerabilitystate) | Filter vulnerabilities by state. |
##### `Group.workItemTypes`
Work item types available to the group. Returns `null` if `work_items` feature flag is disabled. This flag is disabled by default, because the feature is experimental and is subject to change without notice.
Returns [`WorkItemTypeConnection`](#workitemtypeconnection).
This field returns a [connection](#connections). It accepts the
four standard [pagination arguments](#connection-pagination-arguments):
`before: String`, `after: String`, `first: Int`, `last: Int`.
###### Arguments
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="groupworkitemtypestaskable"></a>`taskable` | [`Boolean`](#boolean) | If `true`, only taskable work item types will be returned. Argument is experimental and can be removed in the future without notice. |
### `GroupMember`
Represents a Group Membership.
......@@ -13774,7 +13789,6 @@ Represents vulnerability finding of a security report on the pipeline.
| <a id="projectvulnerabilityscanners"></a>`vulnerabilityScanners` | [`VulnerabilityScannerConnection`](#vulnerabilityscannerconnection) | Vulnerability scanners reported on the project vulnerabilities. (see [Connections](#connections)) |
| <a id="projectweburl"></a>`webUrl` | [`String`](#string) | Web URL of the project. |
| <a id="projectwikienabled"></a>`wikiEnabled` | [`Boolean`](#boolean) | Indicates if Wikis are enabled for the current user. |
| <a id="projectworkitemtypes"></a>`workItemTypes` | [`WorkItemTypeConnection`](#workitemtypeconnection) | Work item types available to the project. Returns `null` if `work_items` feature flag is disabled. This flag is disabled by default, because the feature is experimental and is subject to change without notice. (see [Connections](#connections)) |
#### Fields with arguments
......@@ -14728,6 +14742,22 @@ Returns [`VulnerabilitySeveritiesCount`](#vulnerabilityseveritiescount).
| <a id="projectvulnerabilityseveritiescountseverity"></a>`severity` | [`[VulnerabilitySeverity!]`](#vulnerabilityseverity) | Filter vulnerabilities by severity. |
| <a id="projectvulnerabilityseveritiescountstate"></a>`state` | [`[VulnerabilityState!]`](#vulnerabilitystate) | Filter vulnerabilities by state. |
##### `Project.workItemTypes`
Work item types available to the project. Returns `null` if `work_items` feature flag is disabled. This flag is disabled by default, because the feature is experimental and is subject to change without notice.
Returns [`WorkItemTypeConnection`](#workitemtypeconnection).
This field returns a [connection](#connections). It accepts the
four standard [pagination arguments](#connection-pagination-arguments):
`before: String`, `after: String`, `first: Int`, `last: Int`.
###### Arguments
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="projectworkitemtypestaskable"></a>`taskable` | [`Boolean`](#boolean) | If `true`, only taskable work item types will be returned. Argument is experimental and can be removed in the future without notice. |
### `ProjectCiCdSetting`
#### Fields
......@@ -20,6 +20,14 @@ RSpec.describe Resolvers::WorkItems::TypesResolver do
expect(result.to_a).to match(WorkItems::Type.default.order_by_name_asc)
end
context 'when requesting taskable types' do
it 'returns only taskable types' do
result = resolve(described_class, obj: group, args: { taskable: true })
expect(result.to_a).to contain_exactly(WorkItems::Type.default_by_type(:task))
end
end
context 'when work_items feature flag is disabled' do
before do
stub_feature_flags(work_items: false)
......
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