gitlab-org--gitlab-foss/app/graphql/types/time_type.rb

19 lines
381 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module Types
class TimeType < BaseScalar
graphql_name 'Time'
description 'Time represented in ISO 8601'
2017-08-16 13:04:41 +00:00
def self.coerce_input(value, ctx)
Time.parse(value)
rescue ArgumentError, TypeError => e
raise GraphQL::CoercionError, e.message
end
def self.coerce_result(value, ctx)
value.iso8601
end
end
2017-08-16 13:04:41 +00:00
end