module GraphQL::PersistedQueries::ErrorHandlers

Contains factory methods for error handlers

Public Class Methods

build(handler, **options) click to toggle source
# File lib/graphql/persisted_queries/error_handlers.rb, line 10
def self.build(handler, **options)
  if handler.is_a?(ErrorHandlers::BaseErrorHandler)
    handler
  elsif handler.is_a?(Proc)
    build_from_proc(handler)
  else
    build_by_name(handler, **options)
  end
end
build_by_name(name, **options) click to toggle source
# File lib/graphql/persisted_queries/error_handlers.rb, line 28
def self.build_by_name(name, **options)
  const_get("#{BuilderHelpers.camelize(name)}ErrorHandler").new(**options)
rescue NameError => e
  raise e.class, "Persisted query error handler for :#{name} haven't been found", e.backtrace
end
build_from_proc(proc) click to toggle source
# File lib/graphql/persisted_queries/error_handlers.rb, line 20
def self.build_from_proc(proc)
  if proc.arity != 1
    raise ArgumentError, "proc passed to :error_handler should have exactly one argument"
  end

  proc
end