Commit 89f159ba authored by Dylan Griffith's avatar Dylan Griffith

Merge branch '350200-add-actor-to-work-item-types-field-ff' into 'master'

Add an actor to FF check on work item type resolver

See merge request gitlab-org/gitlab!82154
parents 52d624df df5275d9
...@@ -6,6 +6,8 @@ module Resolvers ...@@ -6,6 +6,8 @@ module Resolvers
type Types::WorkItems::TypeType.connection_type, null: true type Types::WorkItems::TypeType.connection_type, null: true
def resolve def resolve
return unless Feature.enabled?(:work_items, object)
# This will require a finder in the future when groups/projects get their work item types # 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 # All groups/projects use the default types for now
::WorkItems::Type.default.order_by_name_asc ::WorkItems::Type.default.order_by_name_asc
......
...@@ -209,8 +209,9 @@ module Types ...@@ -209,8 +209,9 @@ module Types
field :work_item_types, Types::WorkItems::TypeType.connection_type, field :work_item_types, Types::WorkItems::TypeType.connection_type,
resolver: Resolvers::WorkItems::TypesResolver, resolver: Resolvers::WorkItems::TypesResolver,
description: 'Work item types available to the group.', description: 'Work item types available to the group.' \
feature_flag: :work_items ' 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.'
def label(title:) def label(title:)
BatchLoader::GraphQL.for(title).batch(key: group) do |titles, loader, args| BatchLoader::GraphQL.for(title).batch(key: group) do |titles, loader, args|
......
...@@ -397,8 +397,9 @@ module Types ...@@ -397,8 +397,9 @@ module Types
field :work_item_types, Types::WorkItems::TypeType.connection_type, field :work_item_types, Types::WorkItems::TypeType.connection_type,
resolver: Resolvers::WorkItems::TypesResolver, resolver: Resolvers::WorkItems::TypesResolver,
description: 'Work item types available to the project.', description: 'Work item types available to the project.' \
feature_flag: :work_items ' 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.'
def label(title:) def label(title:)
BatchLoader::GraphQL.for(title).batch(key: project) do |titles, loader, args| BatchLoader::GraphQL.for(title).batch(key: project) do |titles, loader, args|
......
...@@ -11140,7 +11140,7 @@ four standard [pagination arguments](#connection-pagination-arguments): ...@@ -11140,7 +11140,7 @@ four standard [pagination arguments](#connection-pagination-arguments):
| <a id="groupvisibility"></a>`visibility` | [`String`](#string) | Visibility of the namespace. | | <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="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="groupweburl"></a>`webUrl` | [`String!`](#string) | Web URL of the group. |
| <a id="groupworkitemtypes"></a>`workItemTypes` | [`WorkItemTypeConnection`](#workitemtypeconnection) | Work item types available to the group. Available only when feature flag `work_items` is enabled. This flag is disabled by default, because the feature is experimental and is subject to change without notice. (see [Connections](#connections)) | | <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 #### Fields with arguments
...@@ -13758,7 +13758,7 @@ Represents vulnerability finding of a security report on the pipeline. ...@@ -13758,7 +13758,7 @@ 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="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="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="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. Available only when feature flag `work_items` is enabled. This flag is disabled by default, because the feature is experimental and is subject to change without notice. (see [Connections](#connections)) | | <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 #### Fields with arguments
...@@ -7,16 +7,41 @@ RSpec.describe Resolvers::WorkItems::TypesResolver do ...@@ -7,16 +7,41 @@ RSpec.describe Resolvers::WorkItems::TypesResolver do
let_it_be(:current_user) { create(:user) } let_it_be(:current_user) { create(:user) }
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
before_all do before_all do
group.add_developer(current_user) group.add_developer(current_user)
end end
describe '#resolve' do shared_examples 'a work item type resolver' do
it 'returns all default work item types' do subject(:result) { resolve(described_class, obj: object) }
result = resolve(described_class, obj: group)
it 'returns all default work item types' do
expect(result.to_a).to match(WorkItems::Type.default.order_by_name_asc) expect(result.to_a).to match(WorkItems::Type.default.order_by_name_asc)
end end
context 'when work_items feature flag is disabled' do
before do
stub_feature_flags(work_items: false)
end
it 'returns nil' do
expect(result).to be_nil
end
end
end
describe '#resolve' do
context 'when parent is a group' do
let(:object) { group }
it_behaves_like 'a work item type resolver'
end
context 'when parent is a project' do
let(:object) { project }
it_behaves_like 'a work item type resolver'
end
end end
end end
...@@ -64,8 +64,8 @@ RSpec.describe 'getting a list of work item types for a group' do ...@@ -64,8 +64,8 @@ RSpec.describe 'getting a list of work item types for a group' do
post_graphql(query, current_user: current_user) post_graphql(query, current_user: current_user)
end end
it 'makes the workItemTypes field unavailable' do it 'returns null' do
expect(graphql_errors).to contain_exactly(hash_including("message" => "Field 'workItemTypes' doesn't exist on type 'Group'")) expect(graphql_data.dig('group', 'workItemTypes')).to be_nil
end end
end end
end end
...@@ -64,8 +64,8 @@ RSpec.describe 'getting a list of work item types for a project' do ...@@ -64,8 +64,8 @@ RSpec.describe 'getting a list of work item types for a project' do
post_graphql(query, current_user: current_user) post_graphql(query, current_user: current_user)
end end
it 'makes the workItemTypes field unavailable' do it 'returns null' do
expect(graphql_errors).to contain_exactly(hash_including("message" => "Field 'workItemTypes' doesn't exist on type 'Project'")) expect(graphql_data.dig('project', 'workItemTypes')).to be_nil
end end
end 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