Loading
Add versions connection to the GraphQL TerraformState type
TerraformState exposes latestVersion but there is no way to list the version history of a state. The REST API can fetch a version by serial, which requires already knowing the serial numbers.
This MR adds TerraformState.versions, a paginated connection of TerraformStateVersion ordered by the version serial with the most recent first (the same order latestVersion uses). It reuses the existing versions association and the existing TerraformStateVersion type and authorisation (read_terraform_state), so no new permissions are involved.
Docs and both introspection JSON files are updated by hand.
Resolves #353592
Differences
Before: Only latestVersion is available per state.
After:
{
project(fullPath: "group/project") {
terraformStates {
nodes {
name
versions(first: 10) {
nodes { serial createdAt createdByUser { username } downloadPath }
pageInfo { hasNextPage endCursor }
}
}
}
}
}How to set up and Validate locally:
- Push a few versions of a Terraform state to a project (or create them with the
terraform_state_versionfactory in a Rails console). - Run the query above in GraphiQL; versions come back newest first and
first/afterpage through them. - Specs:
bundle exec rspec spec/graphql/types/terraform/state_type_spec.rb spec/requests/api/graphql/project/terraform/states_spec.rb
Edited by Jeston Singh