Module: ZeroRuby::Types

Defined in:
lib/zero_ruby/types.rb

Overview

Type definitions using dry-types.

When inheriting from ZeroRuby::Mutation or ZeroRuby::InputObject, types are available via the Types module (e.g., Types::String, Types::ID).

Examples:

Basic usage

class MyMutation < ZeroRuby::Mutation
  argument :id, Types::ID
  argument :name, Types::String
  argument :count, Types::Integer.optional
  argument :active, Types::Boolean.default(false)
end

With constraints

class MyMutation < ZeroRuby::Mutation
  argument :title, Types::String.constrained(min_size: 1, max_size: 200)
  argument :count, Types::Integer.constrained(gt: 0)
  argument :status, Types::String.constrained(included_in: %w[draft published])
end

Constant Summary collapse

String =

String type (passes through strings, coerces nil)

Params::String
Integer =

Coerces string numbers to integers (e.g., “42” -> 42)

Params::Integer
Float =

Coerces string numbers to floats (e.g., “3.14” -> 3.14)

Params::Float
Boolean =

Coerces string booleans (e.g., “true” -> true, “false” -> false)

Params::Bool
ID =

Non-empty string ID type

Params::String.constrained(filled: true)
ISO8601Date =

ISO8601 date string -> Date object

Params::Date
ISO8601DateTime =

ISO8601 datetime string -> DateTime object

Params::DateTime