I'm not the only one who doesn't know how to use Datetime
types with GraphQL-Ruby: https://github.com/rmosolgo/graphql-ruby-demo/issues/27, as you can see there are 18 people like me.
How can I use Datetime to some fields like this?
Types::PlayerType = GraphQL::ObjectType.define do
name 'Player'
field :id, !types.ID
field :birth_date, types.Datetime #or what?
field :death_date, !types.Datetime #or what?
field :note, types.String
end
Maybe I have to use this (https://github.com/howtographql/graphql-ruby/blob/master/app/graphql/types/date_time_type.rb):
date_time_type.rb:
Types::DateTimeType = GraphQL::ScalarType.define do
name 'DateTime'
coerce_input ->(value, _ctx) { Time.zone.parse(value) }
coerce_result ->(value, _ctx) { value.utc.iso8601 }
end
Can someone explain it better?