Skip to content

Fix ReleasesResolver to return empty array when project has no releases

Leaminn Ma requested to merge fix-releases-resolver-to-return-array into master

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
Screenshot_2023-06-01_at_9.39.17_AM Screenshot_2023-06-01_at_9.38.44_AM

How to set up and validate locally

  1. Create or find a project that does not have any Releases.
  2. Before checking out this branch, go to http://gdk.test:3000/-/graphql-explorer and observe that the following query produces a null output. (Adjust the project's fullPath as necessary).
query allReleases {
  project(fullPath: "group-a/project-1") {
    id
    releases {
      nodes {
        id
        name
      }
    }
  }
}

Screenshot_2023-06-01_at_9.36.04_AM

  1. Also observe that when you go to the project's Releases page on the UI, the page does not load.

  2. Now checkout this branch and re-run the query. Observe that now the response returns an empty array as expected.

Screenshot_2023-06-01_at_9.36.52_AM

  1. 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.

Related to #413129 (closed)

Edited by Leaminn Ma

Merge request reports