Module: Quail::TypeMap

Defined in:
lib/quail/type_map.rb

Overview

Maps ActiveRecord column types to their corresponding GraphQL type classes.

Constant Summary collapse

MAPPING =
{
  integer: GraphQL::Types::Int,
  bigint: GraphQL::Types::BigInt,
  float: GraphQL::Types::Float,
  decimal: GraphQL::Types::Float,
  string: GraphQL::Types::String,
  text: GraphQL::Types::String,
  boolean: GraphQL::Types::Boolean,
  date: GraphQL::Types::ISO8601Date,
  datetime: GraphQL::Types::ISO8601DateTime,
  time: GraphQL::Types::ISO8601DateTime,
  json: GraphQL::Types::JSON,
  jsonb: GraphQL::Types::JSON
}.freeze

Class Method Summary collapse

Class Method Details

.graphql_types(column) ⇒ Object



21
22
23
24
25
# File 'lib/quail/type_map.rb', line 21

def self.graphql_types(column)
  return GraphQL::Types::ID if column.name == "id"

  MAPPING[column.type] || GraphQL::Types::String
end

.nullable?(column) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/quail/type_map.rb', line 27

def self.nullable?(column)
  column.null
end