Returning nil from a GraphQL resolver results in an exception
Summary
Returning nil
from a GraphQL resolver used with a connection field results in a NoMethodError
.
Steps to reproduce
- Add a new connection field to any GraphQL type
- Use a resolver to resolve that field
- Ensure that the resolver's
#resolve
returnsnil
- From
/-/graphql-explorer
, query for that field. - You should see GraphQL fail with an internal server error
What is the current bug behavior?
Fetching a connection field that uses a resolver that returns nil
results in a 500.
What is the expected correct behavior?
The field should return null
.
Relevant logs and/or screenshots
Possible fixes
Move the authentication check for nil
in Gitlab::GraphQL::Authorize::AuthorizeFieldService#filter_allowed
above the check for a connection field.