Optimize project member access loading with BatchModelLoader in GraphQL
What does this MR do and why?
Issue Link: #562240 (closed)
This merge request simplifies and standardizes the loading of user and group records in the Secrets Management GraphQL API by replacing custom BatchLoader implementations with GitLab's standard BatchModelLoader. The key changes include:
- Replacing custom BatchLoader implementations for user and group records with the standard
Gitlab::Graphql::Loaders::BatchModelLoader - Simplifying conditional logic in the
userandgroupmethods with more concise syntax - Maintaining the use of
id.to_ito ensure proper identifier extraction
Benefits:
- Code simplification: Reduces boilerplate code by leveraging existing batch loading infrastructure
- Standardization: Uses the same pattern for batch loading as other parts of the codebase
- Maintainability: Reduces custom code that needs to be maintained
Security considerations:
Authorization for this endpoint is handled at a higher level, ensuring that only authorized users can access group or user permissions, making additional permission checks in the BatchModelLoader unnecessary.
Implementation notes
The implementation maintains the existing behavior while reducing code complexity. The endpoint's security model remains intact as authorization checks are performed before these loaders are invoked.
References
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
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.