Class: GraphqlRails::Controller::Request::FormatErrors

Inherits:
Object
  • Object
show all
Includes:
Service
Defined in:
lib/graphql_rails/controller/request/format_errors.rb

Overview

Converts user provided free-form errors in to meaningful graphql error classes

Instance Method Summary collapse

Constructor Details

#initialize(not_formatted_errors:) ⇒ FormatErrors

Returns a new instance of FormatErrors.



15
16
17
# File 'lib/graphql_rails/controller/request/format_errors.rb', line 15

def initialize(not_formatted_errors:)
  @not_formatted_errors = not_formatted_errors
end

Instance Method Details

#callObject



19
20
21
22
23
24
25
# File 'lib/graphql_rails/controller/request/format_errors.rb', line 19

def call
  if validation_errors?
    formatted_validation_errors
  else
    not_formatted_errors.map { |error| format_error(error) }
  end
end