Skip to content

Add GQL API for returning a list of projects that use components in a pipeline

Rajendra Kadam requested to merge 466575-projects-using-components into master

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

Screenshot_2024-09-09_at_3.03.14_PM

How to set up and validate locally

  1. Follow the steps mentioned in !165471 for creating some dummy usage records.
  2. Make sure you have Ultimate license installed.
  3. 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 -

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:

self-managed

Query for Self-Managed:

query {
  projectsUsingComponents {
    nodes {
      fullPath
      ciComponentsUsed {
	nodes {
          name
          version
          usedDate
        }
      }
    }
  }
}

Related to #466575

Edited by Rajendra Kadam

Merge request reports

Loading