Skip to content

Add jobTokenPoliciesByCategory to GraphQL root query

What does this MR do and why?

This MR adds a jobTokenPolicies field to the top-level GraphQL query. It returns static data for the job token categories and the policies for each category. This data will be used by frontend to populate the dropdowns for a form.

Query
query {
  jobTokenPoliciesByCategory {
    text
    value
    description
    policies {
      text
      value
      type
      description
    }
  }
}
Response
{
  "data": {
    "jobTokenPoliciesByCategory": [
      {
        "text": "Containers",
        "value": "CONTAINERS",
        "description": "Containers category",
        "policies": [
          {
            "text": "Read",
            "value": "READ_CONTAINERS",
            "type": "READ",
            "description": "Read all container images in a project"
          },
          {
            "text": "Read and write",
            "value": "ADMIN_CONTAINERS",
            "type": "ADMIN",
            "description": "CRUD all container images in a project"
          }
        ]
      },
      {
        "text": "Deployments",
        "value": "DEPLOYMENTS",
        "description": "Deployments category",
        "policies": [
          {
            "text": "Read",
            "value": "READ_DEPLOYMENTS",
            "type": "READ",
            "description": "Read all deployments in a project"
          },
          {
            "text": "Read and write",
            "value": "ADMIN_DEPLOYMENTS",
            "type": "ADMIN",
            "description": "Admin deployments"
          }
        ]
      },
      {
        "text": "Environments",
        "value": "ENVIRONMENTS",
        "description": "Environments category",
        "policies": [
          {
            "text": "Read",
            "value": "READ_ENVIRONMENTS",
            "type": "READ",
            "description": "Read all environments in a project"
          },
          {
            "text": "Read and write",
            "value": "ADMIN_ENVIRONMENTS",
            "type": "ADMIN",
            "description": "CRUD + Stop all environments in a project"
          }
        ]
      },
      {
        "text": "Jobs",
        "value": "JOBS",
        "description": "Jobs category",
        "policies": [
          {
            "text": "Read",
            "value": "READ_JOBS",
            "type": "READ",
            "description": "Read all job metadata and artifacts"
          },
          {
            "text": "Read and write",
            "value": "ADMIN_JOBS",
            "type": "ADMIN",
            "description": "Read all job metadata, upload artifacts and update the pipeline status"
          }
        ]
      },
      {
        "text": "Packages",
        "value": "PACKAGES",
        "description": "Packages category",
        "policies": [
          {
            "text": "Read",
            "value": "READ_PACKAGES",
            "type": "READ",
            "description": "Read, create and delete packages"
          },
          {
            "text": "Read and write",
            "value": "ADMIN_PACKAGES",
            "type": "ADMIN",
            "description": "Admin packages"
          }
        ]
      },
      {
        "text": "Releases",
        "value": "RELEASES",
        "description": "Releases category",
        "policies": [
          {
            "text": "Read",
            "value": "READ_RELEASES",
            "type": "READ",
            "description": "Read all releases in a project"
          },
          {
            "text": "Read and write",
            "value": "ADMIN_RELEASES",
            "type": "ADMIN",
            "description": "CRUD all releases in a project"
          }
        ]
      },
      {
        "text": "Secure files",
        "value": "SECURE_FILES",
        "description": "Secure files category",
        "policies": [
          {
            "text": "Read",
            "value": "READ_SECURE_FILES",
            "type": "READ",
            "description": "Read all secure files in a project"
          },
          {
            "text": "Read and write",
            "value": "ADMIN_SECURE_FILES",
            "type": "ADMIN",
            "description": "CRUD all secure files in a project"
          }
        ]
      },
      {
        "text": "Terraform state",
        "value": "TERRAFORM_STATE",
        "description": "Terraform state category",
        "policies": [
          {
            "text": "Read",
            "value": "READ_TERRAFORM_STATE",
            "type": "READ",
            "description": "Read all terraform state files/version"
          },
          {
            "text": "Read and write",
            "value": "ADMIN_TERRAFORM_STATE",
            "type": "ADMIN",
            "description": "CRUD all terraform state files/versions"
          }
        ]
      }
    ]
  },
  "correlationId": "01JCEE2P7X90RNJTGCF44AT6G4"
}

How to set up and validate locally

Open GraphQL Explorer at http://127.0.0.1:3000/-/graphql-explorer, run the query in the MR description, and verify that the it returns the response in the MR description.

Related to #502304 (closed)

Edited by Daniel Tian

Merge request reports

Loading