Skip to content

Limit GQL CiCatalogResource `versions` field to single resource request

Leaminn Ma requested to merge gql-cicatalog-versions-for-single-resource into master

What does this MR do and why?

This MR accomplishes the following:

  • Resolves the last step of #414500 (closed). The versions field is no longer deprecated because it is still required by the ciCatalogResource (single resource) endpoint. Instead, it is reverted back to alpha state and limited to only a single Catalog Resource node. Performance degradation occurs if it is called on more than one node.
  • Batching has been removed from VersionsResolver and it has been updated to inherit from the ReleasesResolver.
  • Refactored the single resource spec (ee/spec/requests/api/graphql/ci/catalog/resource_spec.rb) so that it is consistent with the one for multiple resources (ee/spec/requests/api/graphql/ci/catalog/resources_spec.rb.

How to set up and validate locally

  1. In the Rails console, run Feature.enable(:ci_namespace_catalog_experimental).
  2. Create a Catalog Resource with an existing or new Project:
::Ci::Catalog::Resource.create(project: Project.find(<project_id>))
  1. Ensure that the Project has a non-empty description and also has a README file. (This is required for you to successfully create a Release on the Catalog Resource.)
  2. Create at least one Tag and one Release on the Project. (Note that a Release is equivalent to a Version of the Catalog Resource.)
  3. Go to http://gdk.test:3000/-/graphql-explorer and run the following query (adjust the id as necessary):
query getCiCatalogResources {
  ciCatalogResource(id: "gid://gitlab/Ci::Catalog::Resource/2") {
    id
    name
    versions {
      nodes {
        tagName
        releasedAt
        author {
          id
          name
          webUrl
        }
      }
    }
  }
}

Observe that the output shows the correct Catalog Resource information along with the versions data.

Screenshot Screenshot_2023-06-16_at_9.40.31_AM
  1. Repeat Step 2 to create at least one other Catalog Resource under the same root namespace as the one created in Step 2.

  2. Now run the following query (adjust projectPath as necessary):

query getCiCatalogResources {
  ciCatalogResources(projectPath: "group-a/project-catalog-resource-1") {
    nodes {
      id
      name
      versions {
        nodes {
          tagName
          releasedAt
          author {
            id
            name
            webUrl
          }
        }
      }
    }
  }
}

Observe that an error results which indicates that the versions field can only be requested for 1 resource at a time:

Screenshot_2023-06-16_at_9.50.13_AM

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 #414500 (closed)

Edited by Leaminn Ma

Merge request reports