Skip to content

Add availableDeployKeys field to projects type

Jerry Seto requested to merge 432494-graphql-deploy-keys-2 into master

What does this MR do and why?

Add availableDeployKeys field to projects

In order to facilitate searching for deploy keys on the client side

  • Expose available deploy keys in project graphql type
  • Accept an argument for querying by deploy key title

New Queries

explain: https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/26769/commands/83527

SELECT "keys".*
FROM "keys"
INNER JOIN "deploy_keys_projects" ON "deploy_keys_projects"."deploy_key_id" = "keys"."id"
WHERE "keys"."type" = 'DeployKey'
  AND "deploy_keys_projects"."can_push" = TRUE
  AND "deploy_keys_projects"."project_id" = 13083
  AND "keys"."title" ILIKE '%sync%'
ORDER BY "keys"."id" DESC LIMIT 101

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.

How to set up and validate locally

  1. Create a project
  2. Add a deploy key to the project with write access
  3. Try querying for the deploy key through projects with different levels of permission (e.g http://gdk.test:3000/-/graphql-explorer as maintainer and developer)
query {
  project(fullPath: "root/project_with_deploy_key") {
    id
    availableDeployKeys(titleQuery: "title"){
      nodes{
        id
        title
      
        user {
         id
        } 
      }
    }
  }
}
  1. See that deploy keys are included in the response when querying with at least maintainer access.

Related to #432494 (closed)

Edited by Jerry Seto

Merge request reports