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
How to set up and validate locally
- Open GraphQL Explorer at
http://localhost:3000/-/graphql-explorer - Run the following query (replace the project path):
{ project(fullPath: "gitlab-org/gitlab-shell") { repository { commits(ref: "master", first: 10) { nodes { shortId title tags } } } } } - Remove
tagsfrom the query and verify in Rails logs that noGitaly:ListRefscall 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.
