Add tags field to Commit GraphQL type

What does this MR do and why?

Contributes to #588848 (closed)

Problem

The Vue-based commit list page needs to display tag badges per commit, but the Commit GraphQL type does not expose tag data. The existing HAML view gets tags via CommitPresenter#tags_for_display after a batch load_tags call, but this is not available to GraphQL consumers.

Solution

Add a tags field to CommitType that returns tag names pointing to a commit, delegating to CommitPresenter#tags_for_display. Include the LooksAhead concern in CommitsResolver to conditionally call CommitCollection#load_tags only when the tags field is in the GraphQL selection set. This makes a single Gitaly ListRefs RPC for all commits on the page, avoiding N+1 queries while skipping the call entirely when tags are not requested.

References

Screenshots or screen recordings

Screenshot_2026-03-27_at_14.31.28

How to set up and validate locally

  1. Open GraphQL Explorer at http://localhost:3000/-/graphql-explorer
  2. Run the following query (replace the project path):
    {
      project(fullPath: "gitlab-org/gitlab-shell") {
        repository {
          commits(ref: "master", first: 10) {
            nodes {
              shortId
              title
              tags
            }
          }
        }
      }
    }
  3. Remove tags from the query and verify in Rails logs that no Gitaly:ListRefs call is made

MR acceptance checklist

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

Edited by Vasilii Iakliushin

Merge request reports

Loading
Loading