Use ruby-graphql version of required: :nullable
What does this MR do and why?
This MR switches our GraphQL codebase from the bespoke implementation for required: :nullable
to the ruby-graphql
gem's native implementation.
The bespoke implementation was added in f93038ec when we were on version
1.11.8
of the gem, but as of version 1.13.3
the gem now supports this exact syntax https://github.com/rmosolgo/graphql-ruby/pull/3784.
The validation of required: :nullable
now happens earlier, in the regular GraphQL query validation phase, where it used to happen later in the resolving phase.
For example, on master
, this query which is missing the required dueDate
argument
mutation {
issueSetDueDate(input: { projectPath: "does/not/exist", iid: "1" }) {
issue {
id
}
errors
}
}
results in a "The resource that you are attempting to access does not exist or you don't have permission to perform this action"
error message, but on this branch it results in a "issueSetDueDate has the wrong arguments"
message.
How to set up and validate locally
A query that uses a required: :nullable
argument should still allow a null
value to be passed for the argument, but not allow the argument to be missing.
For example:
# Is still a valid mutation query
mutation {
issueSetDueDate(input: { projectPath: "foo/bar", iid: "1", dueDate: null }) {
issue {
id
}
errors
}
}
# Is still an invalid mutation query
mutation {
issueSetDueDate(input: { projectPath: "foo/bar", iid: "1" }) {
issue {
id
}
errors
}
}
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.