Add defaultMergeRequestTarget GraphQL field to Project type
What does this MR do and why?
Adds a defaultMergeRequestTarget field to the Project GraphQL type. It resolves Project#default_merge_request_target, the existing backend method that returns the upstream project when it can accept merge requests from the fork, and the fork itself otherwise.
The frontend fix in !255472 (merged) was deriving the target using the mergeRequestsDefaultTargetSelf setting alone, which missed the mr_can_target_upstream? half of the rule and broke two edge cases (upstream disables MRs after the fork; private fork of a public project). Exposing the composed backend value here lets the frontend consume the decision directly instead of maintaining its own copy of the rule.
References
- Frontend fix that will consume this field: !255472 (merged)
- Review thread that found the gap: !255472 (comment 3959567831)
- Related backend MR (
mergeRequestsDefaultTargetSelf,sourcedMergeRequests): !255737 (merged) - Resolves #598206 (closed)
How to set up and validate locally
-
Fork a project in GDK, then run this query in
/-/graphql-exploreragainst the fork:query { project(fullPath: "<fork full path>") { defaultMergeRequestTarget { fullPath } } } -
It returns the upstream project. It returns the fork itself after any one of: enabling Settings > Merge requests > Target project > This project on the fork, disabling merge requests on the upstream project, or making the fork more restrictive than the upstream (for example, private fork of a public project).
-
As a user who cannot see the upstream project, the field returns
null.
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.