blob: 7129b75b8bb8ccf14bb895fa04d2f44f062f9f4f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# frozen_string_literal: true
module Types
class DateType < BaseScalar
graphql_name 'Date'
description 'Date represented in ISO 8601'
def self.coerce_input(value, ctx)
return if value.nil?
Date.iso8601(value)
rescue ArgumentError, TypeError => e
raise GraphQL::CoercionError, e.message
end
def self.coerce_result(value, ctx)
return if value.nil?
value.to_date.iso8601
end
end
end
|