Class: Types::TimeType

Inherits:
BaseScalar
  • Object
show all
Defined in:
app/graphql/types/time_type.rb

Class Method Summary collapse

Class Method Details

.coerce_input(value, ctx) ⇒ Object


14
15
16
17
18
19
20
21
# File 'app/graphql/types/time_type.rb', line 14

def self.coerce_input(value, ctx)
  # arguments can be nil, so don't raise an error
  return if value.nil?

  Time.parse(value)
rescue ArgumentError, TypeError => e
  raise GraphQL::CoercionError, e.message
end

.coerce_result(value, ctx) ⇒ Object


23
24
25
# File 'app/graphql/types/time_type.rb', line 23

def self.coerce_result(value, ctx)
  value.iso8601
end