Add search filter to GLQL
What does this MR do and why?
Adds a Search field to GLQL, accepted as a filter on work items, merge requests, and projects.
Example:
type = Issue AND search = "memory leak"It compiles to the search: GraphQL argument those three sources already accept, so there's no new codegen path. Field type is StringLike, with the = operator only.
Scope change
This MR originally also added a Code source backed by the root-level blobSearch GraphQL field. That has been removed and moved to a chained follow-up MR, per @jiaan's review and a matching suggestion in Duo's.
Reason: the filter is a small change that fits the existing sources. Code has open design questions around scope resolution, pagination, and consumer integration, and those shouldn't hold up the filter.
Every review finding on the earlier version of this MR was against the Code source. None applied to the filter. Those findings are carried over to the chained Code MR, which targets this branch.
How to set up and validate locally
- Check out the branch and build:
cargo build - Run the test suite:
cargo test. The three new tests are namedtest_search_filter_compiles_to_the_search_argument, one each intests/work_items_tests.rs,tests/merge_requests_tests.rs, andtests/project_tests.rs. - To see the generated GraphQL for a query by hand:
cargo test test_search_filter_compiles_to_the_search_argument -- --nocapture - Confirm the schema document is in step with the analyzers — CI diffs it.
cargo run --bin generate-schema && npm run lint:prettier:fixshould leavesrc/schema/schema.jsonunchanged. - To validate end-to-end against a GDK, the companion gitlab!258491 (merged) makes the Rails advanced-search finder pass a caller-supplied term to Elasticsearch instead of its hardcoded match-all. That needs
elasticsearch.enabled: trueingdk.ymland a populated work item index. A GLQL block such astype = Issue and search = "memory leak"then returns only matching work items.
Known limitations
Some escaped strings don't survive the lexer or GraphQL rendering: search = "\d+\.rb", and a single-quoted value containing double quotes (search = 'foo "bar"'). Both are pre-existing lexer and rendering limitations rather than regressions from this change, but they restrict what a search term can express. Found by @jiaan; non-blocking, tracked on gitlab#631271 (closed).
Testing
One test per source asserting the search: argument is emitted. Full suite: 1904 tests pass. cargo clippy --all-targets and cargo fmt clean. src/schema/schema.json regenerated — the diff is the three new search filter entries.
Related to gitlab#631271 (closed)