Skip to content

Fetch group environment scopes via GraphQL

Mireya Andres requested to merge ma/group-env-scope into master

What does this MR do and why?

For #388952 (closed)

This MR introduces the ci_group_env_scope_graphql feature flag.

When the feature flag is enabled, the environment scope dropdown in the CI variables form (for groups) will use the new GraphQL query to fetch environment scopes. This applies to the initial fetch and when fetching with a search term. The request will fetch a maximum of 30 environments.

When the feature flag is disabled, there is no dedicated GraphQL request used for fetching environment scopes. Searching for environment scopes is done on the client-side and does not fire a new request.

Implementation Notes:

The settings for CI Variables exist on an instance-level, group-level, and project-level. The components in ci_variable_list are shared in these contexts.

Child components already pass down hasEnvScopeQuery based on whether or not the instance/group/project has a GraphQL query for environment scopes. If there is no query, the environment scopes are taken from the data received from the fetch request for CI variables.

We have existing specs in the environments dropdown component for when when fetching environments via graphql and when environments are not fetched via graphql.

So for this MR, we only need to provide the GraphQL query in the parent component (ci_group_variables.vue).

Screenshots or screen recordings

Before After
before after

How to set up and validate locally

  1. Enable the feature flag.

    Feature.enable(:ci_group_env_scope_graphql)
  2. You can use the following command to seed your group with environments. Set environment_scope to unique for this test. (Docs)

    # Seed CI variables for group
    # Uses a default of 10 for seed_count, "*" for environment_scope, and `GROUP_VAR_` for the prefix.
    # Set environment_scope is set to "unique", each variable will have its own unique environment
    bundle exec rake "gitlab:seed:ci_variables_group[group_name, seed_count, environment_scope, prefix]"
    
    # Example
    bundle exec rake "gitlab:seed:ci_variables_group[<group_name>, 20, unique]"
  3. For your group, go to Settings > CI/CD > and expand the Variables section. Click Add variable to open the modal.

  4. The dropdown for Environment Scopes should now only fetch 30 environments at most.

  5. When using the search bar in the dropdown, this also queries for at most 30 environments.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Mireya Andres

Merge request reports