38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/graphql/types/iso_8601_date_time.rb', line 38
def self.coerce_result(value, _ctx)
case value
when Date
return value.to_time.iso8601(time_precision)
when ::String
return Time.parse(value).iso8601(time_precision)
else
return value.iso8601(time_precision)
end
rescue StandardError => error
raise GraphQL::Error, "An incompatible object (#{value.class}) was given to #{self}. Make sure that only Times, Dates, DateTimes, and well-formatted Strings are used with this type. (#{error.message})"
end
|