Skip to content

Add GraphQL mutation to update Organization

Abdul Wadood requested to merge 419608-add-organization-update-mutation into master

What does this MR do and why?

This is part of the ongoing Organization work by the grouptenant scale group. Read the blueprint to learn more https://docs.gitlab.com/ee/architecture/blueprints/organization/index.html.

This is a follow-up of !135176 (merged) where we added a mutation to create an organization.

Query plans

  1. https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/24350/commands/77797
Raw query
UPDATE "organizations"
SET "updated_at" = '2023-11-30 08:51:53.651717',
    "name"       = 'git',
    "path"       = 'gitlab2'
WHERE "organizations"."id" = 1033;
  1. https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/24350/commands/77798
Raw query
UPDATE "organization_details"
SET "updated_at"       = '2023-11-30 08:51:53.655069',
    "description"      = 'gitLab',
    "description_html" = '<p data-sourcepos="1:1-1:6" dir="auto">gitLab</p>'
WHERE "organization_details"."organization_id" = 1033;

How to set up and validate locally

  1. Follow the steps here to create an organization !137616 (merged).

  2. Create an organization user with the returned organization id and your user id in rails console: Organizations::OrganizationUser.create(organization_id: 1033, user: <your-user>)

  3. Run the following mutation on https://gdk.test:3000/-/graphql-explorer:

mutation {
  organizationUpdate(
    input: {id: "gid://gitlab/Organizations::Organization/1033", name: "gi", path: "gi", description: "gitLab2"}
  ) {
    organization {
      id
      name
      path
      description
      descriptionHtml
    }
    errors
  }
}

Output:

{
  "data": {
    "organizationUpdate": {
      "organization": {
        "id": "gid://gitlab/Organizations::Organization/1033",
        "name": "gi",
        "path": "gi",
        "description": "gitLab2",
        "descriptionHtml": "<p data-sourcepos=\"1:1-1:7\" dir=\"auto\">gitLab2</p>"
      },
      "errors": []
    }
  }
}

MR acceptance checklist

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

Related to #419608 (closed)

Edited by Abdul Wadood

Merge request reports