Add update mutation for work item decision log

What does this MR do and why?

Add update mutation for work item decision log

Lets users with write access to the decision log edit the title, description, resolution rationale, discussion id, and source link of a decision, whether it is open or resolved. Provided fields are rejected when blank so a decision can never be updated to nothing.

Note: Focusing on updating the non-options related fields for this first iteration. Updating the options themselves falls into territory that is out of scope for v0:

Adding/removing/updating* options

  • *This includes updating which option(s) are selected as well. This requires some further discussion and planning, as this path will then lead to the question of whether we should update resolved_by_id, resolved_at, and resolving_note_id, and whether we should preserve these. I feel this goes into activity feed / supersede / reopening resolved decisions territory, so for simplicity, the first MR will only update the fields mentioned in the previous section.

Related to #627779 (closed)

Database review notes

Database-related changes:

  • ee/app/services/work_items/decisions/update_service.rb
  • ee/app/graphql/mutations/work_items/decisions/update.rb

Updating decisions

Note: values provided are sample values. Query plan is generated from local GDK, seeding 9 decisions for each of 582 eligible work items. This is a new experimental feature, so no data exists in production yet.

Location: ee/app/services/work_items/decisions/update_service.rb:19

UPDATE "work_item_decisions"
SET "updated_at" = now(),
    "title" = 'Which cache should we use?',
    "description" = 'The current cache is slow',
    "resolution_rationale" = 'Redis is already in the stack',
    "discussion_id" = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
    "source_link" = 'https://docs.google.com/document/d/abc123'
WHERE "work_item_decisions"."id" = 5378

Query plan: https://explain.depesz.com/s/5Yfi#html

PK reads & namespace loads:

Decision lookup: ee/app/graphql/mutations/work_items/decisions/update.rb:57

SELECT "work_item_decisions".*
FROM "work_item_decisions"
WHERE "work_item_decisions"."id" = 1
LIMIT 1

Parent work item load, for the authorization check: ee/app/graphql/mutations/work_items/decisions/update.rb:60

SELECT "issues".*
FROM "issues"
WHERE "issues"."id" = 1
LIMIT 1

FE integration notes (graphQL queries)

Update a decision (values are samples)

Note: Blank/nil/empty values for these attributes are currently not allowed; it didn't make much sense to update any of these attributes to empty, but this is open for discussion.

Current iteration update features and decisions summarized here: #627779 (closed)

mutation UpdateDecision($input: WorkItemDecisionUpdateInput!) {
  workItemDecisionUpdate(input: $input) {
    decision {
      id
      title
      description
      resolutionRationale
      discussionId
      sourceLink
    }
    errors
  }
}

{
  "input": {
    "id": "gid://gitlab/WorkItems::Decision/42",
    "title": "Which cache should we use for sessions?",
    "description": "The current cache is slow under load",
    "resolutionRationale": "Redis is already in the stack",
    "discussionId": "gid://gitlab/Discussion/3f1a9c2b7d8e4f5a6b7c8d9e0f1a2b3c4d5e6f70",
    "sourceLink": "https://gitlab.com/example/project/-/issues/1#note_123"
  }
}

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #627779 (closed)

Edited by Richard Chan

Merge request reports

Loading
Loading