Feature Request - Add instance-wide merge requests query to GraphQL API
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Proposal
Currently, GitLab's GraphQL API allows querying merge requests at the project level (project.mergeRequests) and at the group level (group.mergeRequests), but lacks the ability to query merge requests across the entire instance, which is possible in the REST API via the /merge_requests endpoint.
I propose adding a top-level mergeRequests field to the GraphQL API's Query type that would allow users to query merge requests from across the entire instance that they have access to, similar to the REST API's functionality.
Rational
This feature would provide several benefits:
- API Consistency: The REST API already supports instance-wide merge request queries, and having the same capability in the GraphQL API would provide consistency across API interfaces.
- Efficient Data Fetching: A key benefit of GraphQL is the ability to specify exactly which fields to retrieve. Currently, users needing instance-wide merge request data must use the REST API, which returns all fields regardless of whether they're needed.
- Reduced Network Traffic: By allowing clients to specify only the fields they need, this would reduce the amount of data transferred over the network.
- Simplified Client Implementation: Without this endpoint, clients needing instance-wide merge request data must either use the REST API (which requires different handling) or make multiple GraphQL queries to different groups/projects and combine the results client-side.
- Performance Optimization: Applications can optimize their performance by fetching only the data they need, especially for large instances with many merge requests.
Technical Details
The new GraphQL API endpoint would:
- Be added to the root Query type as mergeRequests (similar to how the issues endpoint is implemented)
- Accept similar filtering parameters as the REST API's /merge_requests endpoint
- Return a connection of MergeRequest objects
- Respect user permissions, only showing merge requests the user has access to
- Support standard pagination using the GraphQL connection pattern
Edited by 🤖 GitLab Bot 🤖