-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
250b8d0
commit 210becd
Showing
2 changed files
with
21 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module Types | ||
class Date < Types::BaseScalar | ||
graphql_name "Date" | ||
description "An ISO 8601-encoded date" | ||
|
||
def self.coerce_input(value, _context) | ||
begin | ||
::Date.iso8601(value.to_s) | ||
rescue ArgumentError | ||
raise GraphQL::CoercionError, "cannot coerce `#{value.inspect}` to Date" | ||
end | ||
end | ||
|
||
def self.coerce_result(value, _context) | ||
value | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters