Skip to content

Expose notes and discussion on abuse report graphQL endpoint

Jarka Košanová requested to merge 458264-fetch-abuse-report-notes-prep into master

What does this MR do and why?

We are implementing abuse report notes, they have own model AntiAbuse::Reports::Note. We now need to fetch the notes using graphQL.

This MR extracts fields and methods that can be reused from NoteType and DiscussionType.

Additionally, it exposes the discussions and notes fields on abuse report.

I tried to split this MR into smaller parts but it is almost impossible as the frontend-related builds fail if graphql queries don't match the backend. And backend-related builds fail in case I define only types and they are not included anywhere 🤦

MR acceptance checklist

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

How to set up and validate locally

Run the graphql query to make sure we didn't break anything for existing notes, eg.:

{
  issue(id: "gid://gitlab/Issue/56") {
    id
    discussions {
      nodes {
        id
        replyId
        notes {
          nodes {
            id
            body
            bodyHtml
          }
        }
      }
    }
    notes {
      nodes {
        id
        body
        bodyHtml
      }
    }
  }
}

Before testing the endpoint to fetch abuse report notes, you have to create some notes, eg. by running:

params = { note: 'some note 1', abuse_report_id: 23 }
user = User.first
Notes::AbuseReport::CreateService.new(user, params).execute

And then run the query to fetch the abuse report notes/discussions

{
  abuseReport(id: "gid://gitlab/AbuseReport/23") {
    id
    discussions {
      nodes {
        id
        replyId
        notes {
          nodes {
            id
            body
            bodyHtml
          }
        }
      }
    }
    notes {
      nodes {
        id
        body
        bodyHtml
      }
    }
  }
}

To check the notes in the UI, go to admin - abuse reports - detail of the abuse report you created note(s) for

You won't see note content unless you manually assign this value (note_html) in the database. MR fixing that: !164123 (merged)

Related to #458264

Edited by Jarka Košanová

Merge request reports

Loading