Backend: CI Catalog - Add additional fields to GraphQL query
Summary
After the completion of #393567 (closed), we have a GraphQL query! However, we will need a few more fields in order to populate the data for the CI Resource Items.
Comparing the 2, these are the fields we'd like to add.
Here is the query we've merged for reference
query getCiCatalogResources {
ciCatalogResources {
nodes {
group @client
namespace @client
webPath
latestVersion @client {
tagName
releasedAt
author { # Release author
id
name
webUrl
}
}
statistics @client {
forks
favorites
}
}
}
}
Notice also that resource webPath
is not included in the current query, but we would prefer to have this field come from the back end as well. We do have the info to build a webPath with string literals, but just using a query field seems more bug-proof
[2023-04-18] Updated the query with latestVersion
instead of lastUpdate
per #359047 (comment 1353845939).
Implementation
Usage Example
This is the actual query structure implemented:
query getCiCatalogResources {
ciCatalogResources(projectPath: "group-a/project-catalog-resource-1") {
nodes {
id
name
webPath
starCount # aka "Favorites"
forksCount
versions(first: 1) { # Also supports a `sort` argument; default sorted by released_at descending
nodes {
tagName
releasedAt
author {
id
name
webUrl
}
}
}
rootNamespace {
id
name
path
}
}
}
}
MRs
Description | MR |
---|---|
Add GraphQL field versions to CiCatalogResource |
!120811 (merged) |
Add GraphQL field web_path to CiCatalogResource |
!119253 (merged) |
Add GraphQL fields star_count forks_count to CiCatalogResource |
!119264 (merged) |
Add GraphQL field root_namespace to CiCatalogResource |
!119417 (merged) |
Further discussion
There was uncertainty regarding whether we should implement a latest_version
or versions
field. See details here: #408722 (comment 1418713650)
Resolution: Re-implementing the latest_version
field to replace versions
is strongly suggested. Follow-up issue created: Backend: Add GraphQL CiCatalogResource field `l... (#414500 - closed)