Skip to content

Add Graphql mutation to update timeline event

What does this MR do and why?

Contributes to #344060 (closed)

Adds GraphQL mutation to update a timeline event.

Query example

mutation UpdateTimelineEvent($input: TimelineEventUpdateInput!) {
  timelineEventUpdate(input: $input) {
    timelineEvent {
      id
      author { id username }
      updatedByUser { id username }
      incident { id title }
      note
      noteHtml
      promotedFromNote { id body }
      editable
      action
      occurredAt
      createdAt
      updatedAt
    }
    errors
  }
}

Query variables

{
  "input": {
    "id": "gid://gitlab/IncidentManagement::TimelineEvent/3",
    "note":"<strong>Updated note</strong>",
    "occurredAt": "2022-01-25T11:38:05Z"
  }
}

Screenshots or screen recordings

Before Update After rails c
Screenshot_2022-01-25_at_12.35.38 Screenshot_2022-01-25_at_12.39.23 Screenshot_2022-01-25_at_12.43.30 Screenshot_2022-01-25_at_12.40.16

How to set up and validate locally

  • Navigate to Monitor > Incidents from the left sidebar menu of your GitLab project
  • Create a new incident
  • Run bundle exec rails c
  • Create a new timeline event: IncidentManagement::TimelineEvent.create!(note: "test", note_html: "test", incident: Issue.last, project: Issue.last.project, action: "comment", occurred_at: Time.current)
  • Grab the last timeline event ID IncidentManagement::TimelineEvent.last.id
  • Open http://localhost:3000/-/graphql-explorer
  • Copy & Paste mutation example
  • Copy & Paste mutation query variables and update timeline event ID with the last timeline ID from the previous steps
  • Run the mutations in GraphiQL
  • Check IncidentManagement::TimelineEvent.find(<ID>) in the rails console

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 Vitali Tatarintev

Merge request reports