Skip to content

Allow to specify search field when querying work items with GraphQL

Related to #367886 (closed)

What does this MR do and why?

To be able to specify what fields to search in when querying work items, we need to add a new in argument to complement search in WorkItemsResolver.

Given that this logic exists at the finder level and the in argument is already defined for EpicsResolver, we can move the argument to the concern SearchArguments which would also make it available for:

  • IssuesResolver
  • WorkItemsResolver

We also need to move #validate_search_in_params! to the same concern and add #prepare_search_params to format the param for IssuableFinder#by_search.

Example queries

searchEpics
query searchEpics {
  group(fullPath: "gitlab-org") {
    epics(search: "test", in: [DESCRIPTION, TITLE]) {
      edges {
        node {
          title
          description
        }
      }
    }
  }
}
searchIssues
query searchIssues {
  project(fullPath: "gitlab-org/gitlab-test") {
    issues(search: "test", in: TITLE) {
      edges {
        node {
          title
          description
        }
      }
    }
  }
}

searchWorkItems
query searchWorkItems {
  project(fullPath: "gitlab-org/gitlab-test") {
    workItems(search: "another", in: DESCRIPTION) {
      edges {
        node {
          title
          description
        }
      }
    }
  }
}

How to set up and validate locally

  1. In rails console enable the following flags:
    Feature.enable(:work_items)
    Feature.enable(:work_items_hierarchy)
  2. Visit any group or project pages such as http://127.0.0.1:3000/gitlab-org & http://127.0.0.1:3000/gitlab-org/gitlab-test and create new epics, issues and tasks for testing (tasks can be created from an issue page by adding a new child item).
  3. Visit http://localhost:3000/-/graphql-explorer and use example queries to test the different matching combinations (title only, the description only, or both).
  4. When in param is omitted the query should default to search in title and description. -->

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Eugenia Grieff

Merge request reports

Loading