Add GraphQL resolver, query to fetch group environment scopes
What does this MR do and why?
Related issue: #394750 (closed)
- Adds a new GraphQL resolver to fetch group environment scopes
This new resolver is needed to lessen the load of fetching ALL environments, which would sometimes lead to 503
s when the group has too many environments.
New Queries
Fetch all environment scopes (query plan):
SELECT "ci_group_variables"."environment_scope" FROM "ci_group_variables" WHERE "ci_group_variables"."group_id" = 6772326 GROUP BY "ci_group_variables"."environment_scope" ORDER BY "ci_group_variables"."environment_scope" LIMIT 100
Average query time: Time: 46.262 ms
Search for specific environment scope by name (query plan):
SELECT "ci_group_variables"."environment_scope" FROM "ci_group_variables" WHERE "ci_group_variables"."group_id" = 6772326 AND "ci_group_variables"."environment_scope" = '*' GROUP BY "ci_group_variables"."environment_scope" ORDER BY "ci_group_variables"."environment_scope" LIMIT 100
Average query time: Time: 3.280 ms
Search for similar environment scope names by the regular expression (query plan):
SELECT "ci_group_variables"."environment_scope" FROM "ci_group_variables" WHERE "ci_group_variables"."group_id" = 6772326 AND (LOWER(ci_group_variables.environment_scope) LIKE LOWER('%*%')) GROUP BY "ci_group_variables"."environment_scope" ORDER BY "ci_group_variables"."environment_scope" LIMIT 100
Average query time: Time: 27.820 ms
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
- Navigate to the graphql explorer
http://localhost:3000/-/graphql-explorer. # can be different based on gdk config
- Copy and paste and run the following query to the graphql explorer to test:
query {
group(fullPath: "dmitry") {
environmentScopes(first: 12, search: "production") {
nodes {
name
}
}
}
}
Example of output:
{
"data": {
"group": {
"environmentScopes": {
"nodes": [
{
"name": "production"
},
{
"name": "newscope"
},
{
"name": "*"
}
]
}
}
}
}
Database Queries
TO BE DONE
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.
Edited by Dmytro Biryukov