Skip to content

Add terraform module graphql type

Moaz Khalifa requested to merge 465423-Add-terraform-metadata-graphql-type into master

What does this MR do and why?

In Create packages_terraform_module_metadata table... (!141914 - merged), we introduced the database table to save the metadata of the Terraform Registry modules. Now we need to display this metadata on the UI.

To do so, we need to expose them using GraphQL APIs. In this MR, we introduce a new GraphQL type for the Terraform Registry modules' metadata. This should allow the frontend to query the details like so:

package(id:"gid://gitlab/Packages::Package/285"){
    metadata {
      ... on TerraformMetadata {
        fields {
          root {
            readmeHtml
          }
        }
      }
    }
  }
}

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Screenshot_2024-06-26_at_13.38.03

How to set up and validate locally

  1. Publish a Terraform module. This module can be used for testing.
  2. In rails console, get the global_id of the recently unloaded package/module:
    Packages::Package.terraform_module.last.to_global_id.to_s
  3. In your interactive GraphQL explorer, you can test fetching the metadata using the TerraformModuleMetadata GraphQL type:
{
  package(id: "<package global_id>") {
    metadata {
      ... on TerraformModuleMetadata {
        fields {
          root {
            readmeHtml
            inputs {
              name
              type
              default
              description
            }
            outputs {
              name
              description
            }
            dependencies {
          	  modules {
                name
                source
                version
              }
              providers {
                name
                source
                version
              }
            }
            resources
          }
          submodules {
            name
            readmeHtml
            inputs {
          	name
              description
            }
            outputs {
              name
              description
            }
          }
          examples {
            name
            readmeHtml
            inputs {
          	name
              description
            }
            outputs {
              name
              description
            }
          }
        }
      }
    }
  }
}

Related to #465423 (closed)

Edited by Moaz Khalifa

Merge request reports

Loading