Add terraform module graphql type
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.
How to set up and validate locally
- Publish a Terraform module. This module can be used for testing.
- In rails console, get the
global_id
of the recently unloaded package/module:Packages::Package.terraform_module.last.to_global_id.to_s
- 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