Add GraphQL field `versions` to CiCatalogResource
What does this MR do and why?
Added the versions
field to ciCatalogResource
in GraphQL.
This MR makes a few changes to the ReleasesFinder
so that it can support an array of Projects as input. It also adapts the existing ReleasesResolver
to use batch loading. These changes enable the use of the ReleasesResolver
for the versions
field.
This MR partially resolves #407382 (closed).
Data Context:
- A Catalog Resource has a 1:1 relationship with Project.
- A Project's "Releases" are equivalent to the Catalog Resource's "Versions".
How to set up and validate locally
- In the Rails console, run
Feature.enable(:ci_private_catalog_beta)
and thenFeature.enable(:ci_namespace_catalog_experimental)
. - Create a Catalog Resource with an existing or new Project:
::Ci::Catalog::Resource.create(project: Project.find(<project_id>))
- Ensure that the Project has a non-empty description and also has a README file. (This is required for you to successfully create a Release on the Catalog Resource.)
- Create at least one Tag and one Release on the Project. (Note that the latest Release is equivalent to the "latest version" of the Catalog Resource.)
- Go to
http://gdk.test:3000/-/graphql-explorer
and run the following query (adjust theprojectPath
as necessary):
query getCiCatalogResources {
ciCatalogResources(projectPath: "group-a/project-catalog-resource-1") {
nodes {
id
name
versions(first: 1) {
nodes {
tagName
releasedAt
author {
id
name
webUrl
}
}
}
}
}
}
- Observe that the output shows the correct Catalog Resource information along with the latest version data.
Query Plan
SELECT "releases".* FROM "releases" WHERE "releases"."project_id" IN (7764, 250833, 13083) AND "releases"."tag" IS NOT NULL ORDER BY "releases"."released_at" DESC
Plan link: https://console.postgres.ai/shared/eb47c8f7-4a0d-45f2-b990-72c51a3de460
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 #407382 (closed)
Edited by Leaminn Ma