Add GraphQL search filter and sort by created_at to ciCatalogResources
What does this MR do and why?
This MR:
- Adds the
searchfield to the GraphQL endpointciCatalogResources.The ability to query the resources by search term was already added in !134517 (diffs), so this MR just exposes the field for use. - Adds
created_atsort options to the same endpoint. - Refactors
spec/graphql/resolvers/ci/catalog/resources_resolver_spec.rbfor clarity.
Resolves #429117 (closed).
How to set up and validate locally
- Under the same parent group, create 2 projects with README files named
Orange ProjectandApple Project. (These names just need to be unique. We simply want to set up a situation where only one or both of these projects are returned by the search filter.) - Update the description of
Orange ProjecttoFoo; update the description ofApple ProjecttoOrange. - In the console, first mark
Orange Projectas a catalog resource, then markApple Projectas a catalog resource.
Ci::Catalog::Resource.create!(project: Project.find_by(name: 'Orange Project'))
Ci::Catalog::Resource.create!(project: Project.find_by(name: 'Apple Project'))
- Go to
http://gdk.test:3000/and test the following query (update the group name as necessary):
query {
ciCatalogResources(projectPath: "group-a/orange-project", search: "orange") {
nodes {
id
name
}
}
}
Observe that both projects from Step 1 are in the response.
- If you change the search term to
"apple", then onlyApple Projectwill show.
- Now test the sorting with the following query:
query {
ciCatalogResources(projectPath: "group-a/orange-project", search: "orange", sort: CREATED_ASC) {
nodes {
id
name
}
}
}
Orange Project should appear first in the list.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #429117 (closed)
Edited by Leaminn Ma


