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:

  1. Replacing custom BatchLoader implementations for user and group records with the standard Gitlab::Graphql::Loaders::BatchModelLoader
  2. Simplifying conditional logic in the user and group methods with more concise syntax
  3. Maintaining the use of id.to_i to 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.

Edited by Shabini Rajadas

Merge request reports

Loading