Fix ReleasesResolver to return empty array when project has no releases
What does this MR do and why?
In #413129 (closed), it was discovered that a recent change to the ReleasesResolver
in !120811 (merged) caused the /releases
page to break when a project does not have releases.
This is because !120811 (merged) updated the resolver to use BatchLoader
to support multiple projects as input, and only projects that have releases are mapped to a non-null value. This resulted in the GraphQL response to return a null
value instead of the expected empty array []
.
Per @partiaga's great investigation (thank you!):
BEFORE !120811 (merged) result
{
"data" : {
"project" : {
"name" : "Pipeline Tests",
"releases" : {
"nodes" : []
}
}
}
}
AFTER !120811 (merged) result
{
"data" : {
"project" : {
"name" : "Pipeline Tests",
"releases" : null
}
}
}
This MR updates the ReleasesResolver
to convert the Lazy object values to Array
in order to produce the same output as before.
Screenshots
BEFORE | AFTER |
---|---|
How to set up and validate locally
- Create or find a project that does not have any Releases.
- Before checking out this branch, go to
http://gdk.test:3000/-/graphql-explorer
and observe that the following query produces anull
output. (Adjust the project'sfullPath
as necessary).
query allReleases {
project(fullPath: "group-a/project-1") {
id
releases {
nodes {
id
name
}
}
}
}
-
Also observe that when you go to the project's Releases page on the UI, the page does not load.
-
Now checkout this branch and re-run the query. Observe that now the response returns an empty array as expected.
- And observe that the project's Releases page is populated as expected.
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.
Related to #413129 (closed)