Commit aa4ef84d authored by Etienne Baqué's avatar Etienne Baqué

Merge branch '336611-allow-empty-search-string' into 'master'

Allow empty search string for iterations search

See merge request gitlab-org/gitlab!79284
parents 6970412c 394371fb
...@@ -11191,7 +11191,7 @@ four standard [pagination arguments](#connection-pagination-arguments): ...@@ -11191,7 +11191,7 @@ four standard [pagination arguments](#connection-pagination-arguments):
| <a id="groupiterationsin"></a>`in` | [`[IterationSearchableField!]`](#iterationsearchablefield) | Fields in which the fuzzy-search should be performed with the query given in the argument `search`. Defaults to `[title]`. | | <a id="groupiterationsin"></a>`in` | [`[IterationSearchableField!]`](#iterationsearchablefield) | Fields in which the fuzzy-search should be performed with the query given in the argument `search`. Defaults to `[title]`. |
| <a id="groupiterationsincludeancestors"></a>`includeAncestors` | [`Boolean`](#boolean) | Whether to include ancestor iterations. Defaults to true. | | <a id="groupiterationsincludeancestors"></a>`includeAncestors` | [`Boolean`](#boolean) | Whether to include ancestor iterations. Defaults to true. |
| <a id="groupiterationsiterationcadenceids"></a>`iterationCadenceIds` | [`[IterationsCadenceID!]`](#iterationscadenceid) | Global iteration cadence IDs by which to look up the iterations. | | <a id="groupiterationsiterationcadenceids"></a>`iterationCadenceIds` | [`[IterationsCadenceID!]`](#iterationscadenceid) | Global iteration cadence IDs by which to look up the iterations. |
| <a id="groupiterationssearch"></a>`search` | [`String`](#string) | Query used for fuzzy-searching in the fields selected in the argument `in`. | | <a id="groupiterationssearch"></a>`search` | [`String`](#string) | Query used for fuzzy-searching in the fields selected in the argument `in`. Returns all iterations if empty. |
| <a id="groupiterationssort"></a>`sort` | [`IterationSort`](#iterationsort) | List iterations by sort order. If unspecified, an arbitrary order (subject to change) is used. | | <a id="groupiterationssort"></a>`sort` | [`IterationSort`](#iterationsort) | List iterations by sort order. If unspecified, an arbitrary order (subject to change) is used. |
| <a id="groupiterationsstartdate"></a>`startDate` **{warning-solid}** | [`Time`](#time) | **Deprecated** in 13.5. Use timeframe.start. | | <a id="groupiterationsstartdate"></a>`startDate` **{warning-solid}** | [`Time`](#time) | **Deprecated** in 13.5. Use timeframe.start. |
| <a id="groupiterationsstate"></a>`state` | [`IterationState`](#iterationstate) | Filter iterations by state. | | <a id="groupiterationsstate"></a>`state` | [`IterationState`](#iterationstate) | Filter iterations by state. |
...@@ -13935,7 +13935,7 @@ four standard [pagination arguments](#connection-pagination-arguments): ...@@ -13935,7 +13935,7 @@ four standard [pagination arguments](#connection-pagination-arguments):
| <a id="projectiterationsin"></a>`in` | [`[IterationSearchableField!]`](#iterationsearchablefield) | Fields in which the fuzzy-search should be performed with the query given in the argument `search`. Defaults to `[title]`. | | <a id="projectiterationsin"></a>`in` | [`[IterationSearchableField!]`](#iterationsearchablefield) | Fields in which the fuzzy-search should be performed with the query given in the argument `search`. Defaults to `[title]`. |
| <a id="projectiterationsincludeancestors"></a>`includeAncestors` | [`Boolean`](#boolean) | Whether to include ancestor iterations. Defaults to true. | | <a id="projectiterationsincludeancestors"></a>`includeAncestors` | [`Boolean`](#boolean) | Whether to include ancestor iterations. Defaults to true. |
| <a id="projectiterationsiterationcadenceids"></a>`iterationCadenceIds` | [`[IterationsCadenceID!]`](#iterationscadenceid) | Global iteration cadence IDs by which to look up the iterations. | | <a id="projectiterationsiterationcadenceids"></a>`iterationCadenceIds` | [`[IterationsCadenceID!]`](#iterationscadenceid) | Global iteration cadence IDs by which to look up the iterations. |
| <a id="projectiterationssearch"></a>`search` | [`String`](#string) | Query used for fuzzy-searching in the fields selected in the argument `in`. | | <a id="projectiterationssearch"></a>`search` | [`String`](#string) | Query used for fuzzy-searching in the fields selected in the argument `in`. Returns all iterations if empty. |
| <a id="projectiterationssort"></a>`sort` | [`IterationSort`](#iterationsort) | List iterations by sort order. If unspecified, an arbitrary order (subject to change) is used. | | <a id="projectiterationssort"></a>`sort` | [`IterationSort`](#iterationsort) | List iterations by sort order. If unspecified, an arbitrary order (subject to change) is used. |
| <a id="projectiterationsstartdate"></a>`startDate` **{warning-solid}** | [`Time`](#time) | **Deprecated** in 13.5. Use timeframe.start. | | <a id="projectiterationsstartdate"></a>`startDate` **{warning-solid}** | [`Time`](#time) | **Deprecated** in 13.5. Use timeframe.start. |
| <a id="projectiterationsstate"></a>`state` | [`IterationState`](#iterationstate) | Filter iterations by state. | | <a id="projectiterationsstate"></a>`state` | [`IterationState`](#iterationstate) | Filter iterations by state. |
...@@ -17,7 +17,7 @@ module Resolvers ...@@ -17,7 +17,7 @@ module Resolvers
argument :search, GraphQL::Types::String, argument :search, GraphQL::Types::String,
required: false, required: false,
description: 'Query used for fuzzy-searching in the fields selected in the argument `in`.' description: 'Query used for fuzzy-searching in the fields selected in the argument `in`. Returns all iterations if empty.'
argument :in, [Types::IterationSearchableFieldEnum], argument :in, [Types::IterationSearchableFieldEnum],
required: false, required: false,
...@@ -72,10 +72,6 @@ module Resolvers ...@@ -72,10 +72,6 @@ module Resolvers
if args[:title].present? && (args[:search].present? || args[:in].present?) if args[:title].present? && (args[:search].present? || args[:in].present?)
raise Gitlab::Graphql::Errors::ArgumentError, "'title' is deprecated in favor of 'search'. Please use 'search'." raise Gitlab::Graphql::Errors::ArgumentError, "'title' is deprecated in favor of 'search'. Please use 'search'."
end end
if !args[:search].present? && args[:in].present?
raise Gitlab::Graphql::Errors::ArgumentError, "'search' must be specified when using 'in' argument."
end
end end
def handle_search_params!(args) def handle_search_params!(args)
......
...@@ -66,6 +66,8 @@ RSpec.describe Resolvers::IterationsResolver do ...@@ -66,6 +66,8 @@ RSpec.describe Resolvers::IterationsResolver do
context 'with search and in parameters' do context 'with search and in parameters' do
where(:search, :fields_to_search, :expected_iterations) do where(:search, :fields_to_search, :expected_iterations) do
'' | [] | lazy { all_iterations } '' | [] | lazy { all_iterations }
'' | [:title] | lazy { all_iterations }
'' | [:title, :cadence_title] | lazy { all_iterations }
'iteration' | nil | lazy { plan_cadence.iterations } 'iteration' | nil | lazy { plan_cadence.iterations }
'iteration' | [] | lazy { plan_cadence.iterations } 'iteration' | [] | lazy { plan_cadence.iterations }
'iteration' | [:title] | lazy { plan_cadence.iterations } 'iteration' | [:title] | lazy { plan_cadence.iterations }
...@@ -94,12 +96,6 @@ RSpec.describe Resolvers::IterationsResolver do ...@@ -94,12 +96,6 @@ RSpec.describe Resolvers::IterationsResolver do
end end
end end
it "raises an error when 'in' is specified but 'search' is not" do
expect do
resolve_group_iterations({ in: [:title] })
end.to raise_error(Gitlab::Graphql::Errors::ArgumentError, "'search' must be specified when using 'in' argument.")
end
it "uses 'search' and 'in' arguments to search title" do it "uses 'search' and 'in' arguments to search title" do
expect(resolve_group_iterations({ title: 'iteration' }).items).to contain_exactly(*plan_cadence.iterations) expect(resolve_group_iterations({ title: 'iteration' }).items).to contain_exactly(*plan_cadence.iterations)
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