Update timeline event create mutation and list query to consider event tags
What does this MR do and why?
This MR adds support for creating links between TimelineEvent's and TimelineEventTag's.
When someone creates a timeline event via GQL API, they can pass tag names as input. Similarly, when they retrieve timeline events, they can read those tags.
There is no UI support for this change in the APIs. No one can add tags to timeline events via the UI as of now.
Screenshots or screen recordings
How to set up and validate locally
- Make sure you have Write access to a project.
- Create tags in a project from the rails console using Project.last.incident_management_timeline_events.create(name: <tag_name>). If tags don't exist in a project, no tags will be associated with the timeline event.
- Attaching below some examples of creating timeline events and retrieving a timeline event GQL queries for you to test with.
Create a timeline event
mutation CreateTimelineEvent($input: TimelineEventCreateInput!) {
  timelineEventCreate(input: $input) {
    timelineEvent {
      id
      author { id username }
      updatedByUser { id username }
      incident { id title }
      note
      noteHtml
      editable
      promotedFromNote { id body }
      timelineEventTags {
        nodes {
          name
        }
      }
      action
      occurredAt
      createdAt
      updatedAt
    }
    errors
  }
}Sample input:
{
  "input": {
    "incidentId": "<incident_global_id>",
    "note": "Note",
    "occurredAt": "2022-01-19T12:22:42Z",
    "timelineEventTagNames": [<tag_names separated by comma>]
  }
}Retrieve single timeline event
query Extract($fullPath: ID!, $incidentId: IssueID!, $id: IncidentManagementTimelineEventID!) {
  project(fullPath: $fullPath) {
    incidentManagementTimelineEvent(incidentId: $incidentId, id: $id) {
      id
      author { id username }
      updatedByUser { id username }
      incident { id title }
      note
      noteHtml
      promotedFromNote { id body }
      timelineEventTags {
        nodes {
          name
        }
      }
      editable
      action
      occurredAt
      createdAt
      updatedAt
    }
  }
}
Sample input:
{
  "fullPath": "flightjs/Flight",
  "incidentId": "gid://gitlab/Issue/496",
  "id": "gid://gitlab/IncidentManagement::TimelineEvent/136"
}
Query plan and query for `timeline_event.timeline_event_tags`
Plan: https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/12728/commands/44789Query:
explain SELECT "incident_management_timeline_event_tags".* FROM "incident_management_timeline_event_tags" INNER JOIN "incident_management_timeline_event_tag_links" ON "incident_management_timeline_event_tags"."id" = "incident_management_timeline_event_tag_links"."timeline_event_tag_id" WHERE "incident_management_timeline_event_tag_links"."timeline_event_id" = 1Query for project.incident_management_timeline_event_tags.by_names()
Plan: https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/12728/commands/44791
Query:
explain SELECT "incident_management_timeline_event_tags".* FROM "incident_management_timeline_event_tags" WHERE "incident_management_timeline_event_tags"."project_id" = 278964 AND "incident_management_timeline_event_tags"."name" IN ('Test tag 1')Related to #373853 (closed)
Edited  by Rajendra Kadam