Add GraphQL endpoints to fetch abuse report and abuse report labels
What does this MR do and why?
Partially resolves https://gitlab.com/gitlab-org/modelops/anti-abuse/team-tasks/-/issues/167
This MR introduces GraphQL endpoints to fetch an abuse report record and abuse report labels. These endpoints are used to implement showing of abuse report labels and adding/removing labels to an abuse report.
Related MRs
- Add GraphQL endpoints that will be used to display abuse report labels
👈🏼 You are here - Implement show abuse report labels and adding/removing labels to an abuse report
- Implement create abuse report labels (MR yet to be created)
Database changes
Admin::AbuseReportLabelsFinder.new(...).execute
Without search_term
param
Explained: https://console.postgres.ai/shared/76f80919-da32-499e-aa02-2362e6770e16
Raw query
SELECT
"labels".*
FROM
"labels"
WHERE
"labels"."type" = 'Admin::AbuseReportLabel'
ORDER BY
"labels"."title" ASC,
"labels"."id" DESC
LIMIT 101
With search_term
param
Explained: https://console.postgres.ai/shared/53144c6f-27bb-4c54-b7ca-2d0ab2110306
Raw query
SELECT
"labels".*
FROM
"labels"
WHERE
"labels"."type" = 'Admin::AbuseReportLabel'
AND ("labels"."title" ILIKE '%400%'
OR "labels"."description" ILIKE '%400%')
ORDER BY
"labels"."title" ASC,
"labels"."id" DESC
LIMIT 101
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Fetch an abuse report | Fetch abuse report labels |
---|---|
![]() |
![]() |
How to set up and validate locally
Validate abuse report labels GraphQL endpoint
- Login with an admin user (
root
) - Create abuse report label records
$ rails console > Admin::AbuseReportLabel.create("Label One") > Admin::AbuseReportLabel.create("Label Two")
- Go to localhost:3000/-/graphql-explorer and run the following query:
{ abuseReportLabels(searchTerm: "") { nodes { id title description color textColor } } }
- Validate that the output looks like:
{ "data": { "abuseReportLabels": { "nodes": [ { "id": "gid://gitlab/Admin::AbuseReportLabel/124", "title": "Label One", "description": null, "color": "#6699cc", "textColor": "#FFFFFF" }, { "id": "gid://gitlab/Admin::AbuseReportLabel/126", "title": "Label Three", "description": null, "color": "#6699cc", "textColor": "#FFFFFF" }, { "id": "gid://gitlab/Admin::AbuseReportLabel/125", "title": "Label Two", "description": null, "color": "#6699cc", "textColor": "#FFFFFF" } ] } } }
Validate abuse report GraphQL endpoint
- Get a Global ID of an existing abuse report
$ rails console > Gitlab::GlobalId.build(AbuseReport.last, id: AbuseReport.last.id).to_s => "gid://gitlab/AbuseReport/76"
- Go to localhost:3000/-/graphql-explorer and run the following query:
{ # Replace gid://gitlab/AbuseReport/76 with the ID you got from the previous step abuseReport(id: "gid://gitlab/AbuseReport/76") { labels { nodes { id title description color textColor } } } }
- Validate that you get an output that looks like:
{ "data": { "abuseReport": { "labels": { "nodes": [ { "id": "gid://gitlab/Admin::AbuseReportLabel/124", "title": "Label One", "description": null, "color": "#6699cc", "textColor": "#FFFFFF" }, { "id": "gid://gitlab/Admin::AbuseReportLabel/125", "title": "Label Two", "description": null, "color": "#6699cc", "textColor": "#FFFFFF" } ] } } } }
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.