Add mutation to promote timeline event from a note
What does this MR do and why?
Contributes to #344058 (closed)
Adds a GraphQL mutation to promote a timeline event from a note.
I've considered two different solutions here.
One is to extend and reuse an existing GraphQL Mutation for creating timeline events (CreateTimelineEvent
) introduced in !78884 (merged).
Another (current) is to have a separate mutation to promote a comment to a timeline event.
To reuse the existing CreateTimelineEvent
mutation, we would need to modify it to accept two different input sets:
- With provided
incident_id
,note
, andoccured_at
. With blankpromoted_from_note_id
. - With provided
promoted_from_note_id
. With blank (or ignored)incident_id
,note
, andoccured_at
.
I found the approach, with a separate migration, simpler and less confusing. With that approach, we would have two migrations. Each of them will be responsible for their only job.
Screenshots or screen recordings
Before | Mutation | After |
---|---|---|
GraphQL Mutation
Mutation
mutation PromoteTimelineEvent($input: TimelineEventPromoteFromNoteInput!) {
timelineEventPromoteFromNote(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": {
"noteId": "gid://gitlab/Note/1404"
}
}
How to set up and validate locally
- Navigate to Monitor > Incidents from the left sidebar menu of your GitLab project
- Create a new incident
- Create a new comment on the incident's page
- Grab the last comment ID
- Call
Note.last.id
frombundle exec rails c
- Or by inspecting HTML source of the page and find
li
tag with idid="note_<id>"
- Call
- Open
http://localhost:3000/-/graphql-explorer
- Copy & Paste mutation example
- Copy & Paste mutation query variables and update note ID with the note ID from the previous steps
- Run the mutations in GraphiQL
- Check
IncidentManagement::TimelineEvent.find(<TimeLineID>)
in therails 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.
-
I have evaluated the MR acceptance checklist for this MR.