class GraphQL::Types::ISO8601DateTime
own DateTime type.
Alternatively, use this built-in scalar as inspiration for your
argument :deliver_at, GraphQL::Types::ISO8601DateTime, null: false
field :created_at, GraphQL::Types::ISO8601DateTime, null: false
Use it for fields or arguments as follows:
using ISO 8601 format.
This scalar takes ‘DateTime`s and transmits them as strings,
def self.coerce_input(str_value, _ctx)
-
(DateTime)
-
Parameters:
-
str_value
(String
) --
def self.coerce_input(str_value, _ctx) DateTime.iso8601(str_value) rescue ArgumentError # Invalid input nil end
def self.coerce_result(value, _ctx)
-
(String)
-
Parameters:
-
value
(DateTime
) --
def self.coerce_result(value, _ctx) value.iso8601(time_precision) rescue ArgumentError raise GraphQL::Error, "An incompatible object (#{value.class}) was given to #{self}. Make sure that only DateTimes are used with this type." end
def self.time_precision
-
(Integer)
-
def self.time_precision @time_precision || DEFAULT_TIME_PRECISION end
def self.time_precision=(value)
-
value
(Integer
) --
def self.time_precision=(value) @time_precision = value end