Skip to content

Add star count option to GQL ciCatalogResources endpoint

Leaminn Ma requested to merge add-gql-ci-catalog-sort-by-star into master

What does this MR do and why?

Adds the option to sort by star count when querying the ciCatalogResources endpoint in GraphQl.

Resolves #432449 (closed).

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

  1. Seed 5 published catalog resources on your local gdk by executing the following. (Update the first parameter with an existing Group path.)
bundle exec rake "gitlab:seed:ci_catalog_resources[group-a, 5, true]"
  1. In the Rails console, assign a random star count value to each catalog resource project:
Ci::Catalog::Resource.all.each do |resource|
  resource.project.update!(star_count: rand(100))
end
  1. In http://gdk.test:3000/-/graphql-explorer, test the following query.
query getSortedCatalogResources {
  ciCatalogResources(sort: STAR_COUNT_ASC) {
    nodes {
      name
      starCount
    }
  }
}

The result should show the resources in order of star count ascending.

Screenshot_2024-02-20_at_4.42.58_PM

  1. Update the sort parameter to STAR_COUNT_DESC. The result should show the resources in order of star count descending.

Screenshot_2024-02-20_at_4.43.22_PM

Related to #432449 (closed)

Edited by Leaminn Ma

Merge request reports