module GraphQL::Schema::CatchallMiddleware

In early GraphQL versions, errors would be “automatically” rescued and replaced with `“Internal error”`. That behavior was undesirable but this middleware is offered for people who want to preserve it.

It has a couple of differences from the previous behavior:

@example Use CatchallMiddleware with your schema

# All errors will be suppressed and replaced with "Internal error" messages
MySchema.middleware << GraphQL::Schema::CatchallMiddleware

Constants

MESSAGE

Public Class Methods

call(parent_type, parent_object, field_definition, field_args, query_context) { || ... } click to toggle source

Rescue any error and replace it with a {GraphQL::ExecutionError} whose message is {MESSAGE}

# File lib/graphql/schema/catchall_middleware.rb, line 28
def self.call(parent_type, parent_object, field_definition, field_args, query_context)
  yield
rescue StandardError
  GraphQL::ExecutionError.new(MESSAGE)
end