Class: Types::DateType

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

Class Method Summary collapse

Class Method Details

.coerce_input(value, ctx) ⇒ Object


8
9
10
11
12
13
14
# File 'app/graphql/types/date_type.rb', line 8

def self.coerce_input(value, ctx)
  return if value.nil?

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

.coerce_result(value, ctx) ⇒ Object


16
17
18
19
20
# File 'app/graphql/types/date_type.rb', line 16

def self.coerce_result(value, ctx)
  return if value.nil?

  value.to_date.iso8601
end