Add visibility_level/include_subgroups filter arguments to Query.groups for list_groups MCP tool

Note

This is not an MCP tool issue itself — it's a small GraphQL API prerequisite for #607719 (list_groups MCP tool), found while redirecting that issue's implementation plan from an undecided REST/GraphQL question to the existing Query.groups query.

Problem Statement / Use Case

#607719 proposes two filters for list_groups: visibility (public/internal/private) and include_subgroups (recursively include descendant subgroups when parent_id is set). Both are already supported by GroupsFinder (app/finders/groups_finder.rb) — params[:visibility] and params[:include_parent_descendants] — but neither is exposed as an argument on Resolvers::Namespaces::BaseGroupsResolver (app/graphql/resolvers/namespaces/base_groups_resolver.rb), so Query.groups can't express either filter today.

Resolvers::ProjectsResolver already exposes the equivalent project-side filter (argument :visibility_level, ::Types::VisibilityLevelsEnum), so this isn't new API surface for the schema — just the same pattern, applied to groups.

Proposed Change

Add two arguments to Resolvers::Namespaces::BaseGroupsResolver, siblings to the existing top_level_only/parent_path arguments:

  • visibility_level (Types::VisibilityLevelsEnum, singular, matching ProjectsResolver's existing argument name and type) → GroupsFinder's params[:visibility].
  • include_subgroups (GraphQL::Types::Boolean, default false) → GroupsFinder's params[:include_parent_descendants]. Only meaningful in combination with parent_path; a no-op otherwise, same as how GroupsFinder already treats include_parent_descendants without a parent.

Resources

  • app/graphql/resolvers/namespaces/base_groups_resolver.rb — add both arguments alongside top_level_only, parent_path, search.
  • app/finders/groups_finder.rb (docstring at the top already documents both params) and app/finders/concerns/namespaces/groups_filter.rb's by_visibility/visibility_levels — the finder-side support already exists, this is purely exposing it.
  • app/graphql/resolvers/projects_resolver.rbargument :visibility_level, ::Types::VisibilityLevelsEnum is the precedent to copy for naming/type.
  • app/graphql/types/visibility_levels_enum.rb — already public, reuse as the argument type.

Implementation Plan

  1. Add argument :visibility_level, ::Types::VisibilityLevelsEnum, required: false, description: 'Filter groups by visibility level.' to BaseGroupsResolver, and pass it through as params[:visibility] in resolve_groups.
  2. Add argument :include_subgroups, GraphQL::Types::Boolean, required: false, default_value: false, description: 'Include descendant subgroups when filtering by parent_path.', passed through as params[:include_parent_descendants].
  3. Specs: resolver spec covering visibility_level filtering and include_subgroups combined with parent_path (including the no-op case when parent_path is absent), and spec/graphql/all_queries_spec.rb coverage once #607719 commits its .graphql file using the new arguments.
Edited by 🤖 GitLab Bot 🤖