Module: Recline::Types

Defined in:
lib/recline.rb

Constant Summary collapse

AppearanceEnumType =
GraphQL::EnumType.define do
  name "#{Recline.schema_name_prefix}Appearance"
  Recline::Appearance.types.each do |sym|
    value(sym.to_s.upcase, sym.to_s.capitalize, value: sym.to_sym)
  end
end
ModelReflectionType =
GraphQL::Rails::ActiveReflection::Types::ModelReflectionType.redefine do
  name 'ReclineModel'
  field :attributes, Recline::Types::AttributeReflectionType.to_list_type
end
AttributeReflectionType =
GraphQL::Rails::ActiveReflection::Types::AttributeReflectionType.redefine do
  name "ReclineAttribute"
  field :appearance, Recline::Types::AppearanceEnumType
  field :createdAt, types.String, property: :created_at
  field :updatedAt, types.String, property: :updated_at

  field :read_only, types.Boolean do
    resolve ->(obj, _args, _ctx) do
      obj.primary_key?
    end
  end
end