Backend: Add search for CI variables
Problem
Searching for a given CI variable is challenging and causing some pain for our users. With !110817 (merged) merged, we now paginate CI Variables under the ci_variables_pages
feature flag for frontend. Some projects can have up to 200+ variables, so the pagination will make searching for a specific variable into a frustrating experience with users manually clicking through each page to find what they're looking for.
As such, we want to add a search bar to the CI Variables settings to make this experience easier.
See #380873 (closed) for additional context.
Solution
In order to add search capability for #392947 we need to implement the backend for it for the following GraphQL types:
These GraphQL queries already exist. We should add the ability for frontend to pass an optional searchTerm
in the fetch query to filter the results based on the search term. If searchTerm
is not given, or if it does not exist, the fetch query will return the CI variables normally.
Note that since we're paginating, frontend will only be getting 20 results at a time per page. Also, there already exists a sort
argument in the fetch query, which allows the user to sort in ascending or descending order.
For example:
query {
project(fullPath: "project/path") {
id
ciVariables(first: 20, after: 'eyJrZXkiOiJURVNUXzI2IiwiaWQiOiIyOSJ9', sort: 'KEY_ASC' searchTerm: 'env_') {
limit
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
nodes {
id
key
value
variableType
environmentScope
masked
protected
raw
}
}
}
}