Update Timeline event update mutation to consider timeline event tags
What does this MR do and why?
This MR adds support to update timeline event tags on a timeline event.
The way this works is the API expects the net result of tag updates to do on a timeline event.
For example, assume there are event1
, tag1
, tag2
, and tag3
on a project. event1
is already assigned with tag1
. We need to update it with tag3
. So from the front end, I will get [tag1, tag3]
. So I compute the tags to add and tags to remove and assign/unassign them accordingly.
If I have to delete the assigned tags on event1
, then the frontend passes me the []
tags value. This means, we need to delete all tag links to the event and it will not have any assigned tags. If the value for tags from frontend is the same as the assigned tags, then I do not perform any operation regarding tag updates on the event.
Query plan for the scopes
-
by_names
: https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/13345/commands/46839 -
timeline_event.timeline_event_tags
: https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/13345/commands/46840
Mutation
Sample mutation
mutation UpdateTimelineEvent($input: TimelineEventUpdateInput!) {
timelineEventUpdate(input: $input) {
timelineEvent {
id
note
timelineEventTags {
nodes {
name
}
}
}
errors
}
}
Sample input
{
"input": {
"id": "<global id of the incident>",
"note":"<strong>Updated note</strong>",
"occurredAt": "2022-01-25T11:38:05Z",
"timelineEventTagNames": [<name of the tag>]
}
}
How to set up and validate locally
- Make sure you have maintainer access to a project.
- Create some tags using GraphQL by following the steps mentioned in !102870 (merged)
- Create a timeline event using the UI by following the steps mentioned in the docs.
- Get the global id of the above timeline event from the console using
IncidentManagement::TimelineEvent.last.to_global_id
. - Follow the update mutation above with the above sample input to update the event.
- Pass some non-existing tags, remove some tags, add some tags using the API and check the result.
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.
Related to #373853 (closed)