Exception: GraphSQL::UnknownColumnError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/graphsql/unknown_column_error.rb

Overview

Raised by Resolver#select_columns when a graphsql_column/required_columns: entry names something that isn't an actual column on the model — a plain Ruby method, a virtual attribute with no DB backing, or a typo. Without this check the same mistake surfaced as a raw ActiveRecord::StatementInvalid ("no such column: ...") from deep inside Arel/the SQL driver, with nothing pointing back at the offending graphsql_column call.

Class Method Summary collapse

Class Method Details

.for_mapped_column(type:, field:, column:, model:) ⇒ Object



12
13
14
15
# File 'lib/graphsql/unknown_column_error.rb', line 12

def self.for_mapped_column(type:, field:, column:, model:)
  new("#{type}'s graphsql_column #{field.inspect} maps to `#{column}`, " \
      "but #{model} has no such column")
end

.for_required_column(column:, model:) ⇒ Object



17
18
19
# File 'lib/graphsql/unknown_column_error.rb', line 17

def self.for_required_column(column:, model:)
  new("required_columns: referenced `#{column}`, but #{model} has no such column")
end