Added service and mutation to set user namespace commit email

What does this MR do and why?

Follow up of !107525 (merged) where NamespaceCommitEmailType was exposed 🙂

This MR aims at providing the GraphQL mutation to set the users' namespace commit email 🙂

Screenshots or screen recordings

N.A.

How to set up and validate locally

Use a mutation like this one to change the user commit email based on the namespace:

mutation {
  userSetNamespaceCommitEmail(input: {
    userId: "gid://gitlab/User/20",
    namespaceId: "gid://gitlab/Namespace/29",
    emailId: "gid://gitlab/Email/7"
  }) {
    namespaceCommitEmail {
      id
    }
    errors
  }
}

Passing null or omitting email_id will remove an existing user namespace commit email.

You will need to check the records are successfully create via GraphQL, the rails console or in the database directly:

% rails c
=> Users::NamespaceCommitEmail.last

% gdk psql
=# select * from namespace_commit_emails;

query getUser {
  user(username: "ROOT") {
    namespaceCommitEmails { 
      nodes {
        id
        namespace {
          fullPath
        }
        email {
          email
        }
      }
    }
  }
}

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Lee Tickett

Merge request reports

Loading