The GraphQL specification requires certain assumptions to hold true when executing a query. However, it’s possible that some code would violate that assumption, resulting in a type error.
Here are two type errors that you can customize in GraphQL-Ruby:
null: false returned nilYou can specify behavior in these cases by defining a Schema.type_error hook:
class MySchema < GraphQL::Schema
  def self.type_error(err, query_ctx)
    # Handle a failed runtime type coercion
  end
end
It is called with an instance of GraphQL::UnresolvedTypeError or GraphQL::InvalidNullError and the query context (a GraphQL::Query::Context).
If you don’t specify a hook, you get the default behavior:
nils add an error the response’s "errors" keyGraphQL::UnresolvedTypeErrorAn object that fails type resolution is treated as nil.