Fetch group environment scopes via GraphQL
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
-
Enable the feature flag.
Feature.enable(:ci_group_env_scope_graphql)
-
You can use the following command to seed your group with environments. Set
environment_scope
tounique
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]"
-
For your group, go to Settings > CI/CD > and expand the Variables section. Click
Add variable
to open the modal. -
The dropdown for Environment Scopes should now only fetch 30 environments at most.
-
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.
-
I have evaluated the MR acceptance checklist for this MR.