This could be done by:
- adding custom context key like
context[:rendered_errors] = true
- overriding GraphQL::Schema#type_error logic to:
def type_error(type_error, context)
return nil if type_error.is_a?(GraphQL::InvalidNullError) && context[:rendered_errors]
super()
end
Bonus points:
Make it easier to add hooks before_type_error and after_type_error for adding logger logic or so
def type_error(type_error, context)
before_type_error&.call(type_error, context)
super().tap { |result| after_type_error&.call(type_error, context, result) }
end