Fix cannot return null error on VulnerabilityStateTransitionType.author
requested to merge 412596-cannot-return-null-for-non-nullable-field-vulnerabilitystatetransitiontype-author into master
What does this MR do and why?
The author_id
column is nullable in the database.
This causes VulnerabilityStateTransitionType.author
to throw a GraphQL error when the value is null
.
How to set up and validate locally
- Nullify the author on a local
Vulnerability::StateTransition
in the rails console, and obtain thevulnerability_id
:
vst = Vulnerabilities::StateTransition.last
vst.update(author_id: nil)
puts vst.vulnerability_id
- Run the following query in in your gdk
/-/graphql-explorer
, replacingvulnerability_id
query
{
vulnerability(id: "gid://gitlab/Vulnerability/<vulnerability_id>")
{
id
title
stateTransitions {
nodes {
author {
id
}
}
}
}
}
Prior to this change the above query will return an error "Cannot return null for non-nullable field VulnerabilityStateTransitionType.author"
After the change the query will run successfully and return a null
author.
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 #412596 (closed)
Edited by Malcolm Locke