debian-mirror-gitlab/app/graphql/types/time_type.rb

19 lines
381 B
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2018-11-08 19:23:39 +05:30
module Types
class TimeType < BaseScalar
graphql_name 'Time'
description 'Time represented in ISO 8601'
def self.coerce_input(value, ctx)
Time.parse(value)
2020-10-24 23:57:45 +05:30
rescue ArgumentError, TypeError => e
raise GraphQL::CoercionError, e.message
2018-11-08 19:23:39 +05:30
end
def self.coerce_result(value, ctx)
value.iso8601
end
end
end