Consume the merge request violations GraphQL endpoint in the compliance report application
Problem to solve
The new MR violations application #342896 (closed) will need to fetch the list of violations from the new GraphQL backend #327119 (closed).
Proposal
Fetch the GraphQL data using apollo client.
Design
Differences between client query and real query
During backend development, the query has been tweaked a bit due to conventions, database requirements or reviewer preferences. These differences are noted here:
Final query
query getComplianceViolations($fullPath: ID!, $filters: ComplianceViolationInput, $sort: ComplianceViolationSort) {
group(fullPath: $fullPath) {
id
mergeRequestViolations(filters: filters, sort: sort) {
nodes {
id
severityLevel
reason
violatingUser {
id
name
username
state
avatarUrl
webUrl
}
mergeRequest {
id
title
mergedAt
milestone {
id
title
}
webUrl
author {
id
name
username
state
avatarUrl
webUrl
}
mergeUser {
id
name
username
state
avatarUrl
webUrl
}
committers {
nodes {
id
name
username
state
avatarUrl
webUrl
}
}
participants {
nodes {
id
name
username
state
avatarUrl
webUrl
}
}
approvedBy {
nodes {
id
name
username
state
avatarUrl
webUrl
}
}
ref: reference
fullRef: reference(full: true)
sourceBranch
sourceBranchExists
targetBranch
targetBranchExists
headPipeline {
detailedStatus {
id
icon
favicon
text
label
group
tooltip
hasDetails
detailsPath
}
}
project {
id
avatarUrl
name
webUrl
complianceFrameworks {
nodes {
id
name
description
color
}
}
}
}
}
}
}
}
-
severity
is nowseverityLevel
-
severityLevel
andreason
will return the enum text not the enum int e.g.CRITICAL
rather than4
-
mergedBy
is nowmergeUser
-
reference
is nowref
-
project
is now a part ofmergeRequest
rather than a separate entity -
createdBefore/createdAfter
are nowmergedBefore/mergedAfter
: https://docs.gitlab.com/ee/api/graphql/reference/#complianceviolationinput -
SEVERITY_ASC/DESC
is nowSEVERITY_LEVEL_ASC/DESC
: https://docs.gitlab.com/ee/api/graphql/reference/#complianceviolationsort
Additional considerations
Show the latest 20 violations by default. Display pagination when there are next / prev pages available - limited to 20.
Implementation plan
frontend weight
-
Consume the data from the backend #327119 (closed).
- Move the the pagination, sort and filter arguments to the violations in
compliance_violations.query.graphql
. - Replace the filter type with the proper GraphQL violations filter type.
- Move the the pagination, sort and filter arguments to the violations in
- Remove the mock API.
- Update the jest specs.
- Add end-to-end specs.