Add GQL API for returning a list of projects that use components in a pipeline
What does this MR do and why?
This MR adds a new GraphQL API to fetch list of projects along with their components usage as required in MVC - Backend: Create fields to make query whic... (#466575) This is an Ultimate licensed feature.
The DB work in model is done as part of !165471 but the changes are present in this MR too which will get removed once the DB work MR is merged.
This MR adds code for GraphQL API. I have attached respective video for SM and SaaS in their respective collapsible section.
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.
Screenshots or screen recordings
Sample response with GraphQL query
How to set up and validate locally
- Follow the steps mentioned in !165471 for creating some dummy usage records.
- Make sure you have Ultimate license installed.
- There are 2 variations to this API as below:
For SaaS
For SaaS, we expect a groupId
in the query as noted in the screenshot. The user calling this API need to be either a owner
or maintainer
of the group for which the data is requested.
Based on the permissions, we return the list of projects and their components usage along with version and name of the component.
Video for SaaS -
Query for SaaS -
query {
projectsUsingComponents(groupId: "gid://gitlab/Group/<groupId-to-be-requested>") {
nodes {
fullPath
ciComponentsUsed {
nodes {
name
version
usedDate
}
}
}
}
}
Follow docs for simulating a SaaS instance locally.
For Self-Managed
For SM, we consider all the projects, by default, to be checked for component usage. The permissions are only applicable to the instance Admin
.
If there is an Ultimate license and the user is an instance admin, then we return the response in similar manner as above. By default, local GDK acts like a Self hosted isntance.
Video for Self-Managed:
Query for Self-Managed:
query {
projectsUsingComponents {
nodes {
fullPath
ciComponentsUsed {
nodes {
name
version
usedDate
}
}
}
}
}
Related to #466575