Load new merge request page pipelines with GraphQL

What does this MR do and why?

With mr_pipelines_graphql on, the Pipelines tab of the new merge request page now uses the GraphQL list, as the existing merge request page does. Until now, this page always used the REST table, so the flag could not be removed.

The list reads Project.newMergeRequestPipelines, from !266573 (merged). That field runs the same finder as the tab and the badge, so:

  • The list shows the branch pipelines of every commit in the compare, not only the head commit.
  • The badge keeps its count after the list loads, including 100+.
  • A merge request from a fork works, because the list checks read_pipeline on the source and the target project.

This MR must merge only after !266573 (merged) is deployed. A merge request dependency enforces this.

Why a separate component

The list is new_merge_request_pipelines_list.vue, a new component. It does not change pipelines_table_wrapper.vue, because most of the wrapper needs a saved merge request: pipeline creation requests, the Run pipeline button and the fork modal. The commit page uses the same pattern with commit_pipelines_list.vue.

The REST table polled every 10 seconds. The new component uses the existing subscriptions instead:

  • ciPipelineStatusUpdated for each running pipeline and each running downstream pipeline, as on the merge request page. The rows update from the normalized cache.
  • ciPipelineStatusesUpdated for the head commit of the source branch. A new branch pipeline of the source branch, with a branch source, loads the list again on the first page. This is the rule of triggered_for_branch in the finder, so tag, merge request and child pipelines on the same commit do not load the list again.

A new pipeline on an older commit of the branch appears only after a reload. The page shows the compare as it was when it loaded, like the Commits and Changes tabs.

It also keeps what the REST table did on this page:

  • It supports retry, cancel and job actions, and it loads the list again after each one.
  • It shows the downstream pipelines from the same query.
  • It pages through the list with keyset pagination. The REST table returned every pipeline at once.

It does not show Run pipeline. The REST table showed the button only when the latest pipeline was a merge request pipeline, and that button needs a merge request.

merge_request_tabs.js mounts the component with initVueApp, like the existing merge request page root since !269491 (merged), when the flag is on and gl.mrWidgetData does not exist. The page passes the branches, the head commit SHA, the project paths and the badge limit as data attributes, through explicit locals of the pipelines partials. CreationsController now pushes mr_pipelines_graphql to the frontend.

Badge count
  • The badge gets the js-pipelines-mr-count class, as on the existing merge request page. The list sends its count to a listener that writes into that element. Without the class, the listener throws TypeError: Cannot set properties of null, and the browser console check fails the feature spec.
  • The server renders the badge with a limit of 100, so it shows 100+ above 100 pipelines. The query asks for count(limit: 100), with the limit from the page, so the server and the list share one value. count(limit: N) returns N + 1 above N, and the list then shows N+.
  • This count is exact. The field loads up to 101 pipelines, so above 100 pipelines it always has the 101st row. Without the limit, the badge would show 101 instead of 100+.
  • The query scores 289 in the static complexity check, above the default of 250, so ee/spec/graphql/all_queries_spec.rb has an override of 290. The page asks for 15 pipelines, which scores 135 at runtime.
Why this is a separate MR from the backend field

During a rolling deployment on GitLab.com, this frontend can reach a backend that does not have newMergeRequestPipelines yet. The request then fails, and the list shows its error state. @gl_introduced(version: "19.6.0") protects self-managed instances, but on GitLab.com both versions report 19.6.

Screenshots or screen recordings

The source branch fix has two commits, 48f0be4b (head) and 12d65c8d, with one branch pipeline on each. A tag pipeline also runs on the head commit.

  • Before (REST): both branch pipelines are listed, and the badge reads Pipelines 2.
  • After (GraphQL): the list is the same. The badge still reads Pipelines 2 after the list loads. The tag pipeline is not listed.
Before, REST (522e5f98) After, GraphQL (ac75fa2c)
before_light after_light
before_dark after_dark
How the screenshots were taken
  • A temporary local feature spec in GDK, not committed. The pipeline IDs differ between the images because each run creates new data.
  • Before: 522e5f98, the head of !266573 (merged), where the page still uses the REST list.
  • After: ac75fa2c, an earlier version of this MR. It rendered the same PipelinesTable from the merge request pipelines wrapper, before the list moved to its own component and before the 100+ badge change.
  • User path: open /<project>/-/merge_requests/new?merge_request[source_branch]=fix&merge_request[target_branch]=master, then select the Pipelines tab.
  • Full page at 1400×1400, scrolled to the tab bar, in light and dark mode.

How to set up and validate locally

  1. Make sure mr_pipelines_graphql is enabled. It is on by default.
  2. Push a branch with two commits, and let a pipeline run on each commit.
  3. Open the new merge request page for that branch, and select the Pipelines tab. Both pipelines are listed, and the badge still reads 2.
  4. Repeat from a fork of the project, with the parent project as the target.

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.

References

Edited by Miguel Rincon

Merge request reports

Loading
Loading