Closed
Description
Describe the bug
Using GraphQL::Types::ISO8601Date
on a custom type's field can produce an invalid_date
error when renderer if the field is a Date
object set to 2024-02-29
.
After analysis, it appears that value.to_s
output Tue 29th Feb.
, and Date.parse(value.to_s)
crash with an invalid_date
error because the year is not present in the input argument (which is necessary for leap days).
Versions
graphql
version: '~> 2.3'
rails
(or other framework): '6.1.7.10'
GraphQL schema
Include relevant types and fields (in Ruby is best, in GraphQL IDL is ok). Any custom extensions, etc?
class CustomType < GraphQL::Introspection::BaseObject
field :id, ID, null: false
field :date, GraphQL::Types::ISO8601Date, null: true
end
GraphQL query
Example GraphQL query and response (if query execution is involved)
query {
custom { id date }
}
Steps to reproduce
- Define a model with
GraphQL::Types::ISO8601Date
field - Plug this model to a data entity that map a
Date
object with the date field. The date should be on a leap day (ie.Date.new(2024, 2, 29)
) - Try to render the model with this data entity through the GraphQL api
Expected behavior
- It outputs the model with the date renderer as a ISO 8601 string (
2024-02-29
)
Actual behavior
- It produces a 500 error, subsequent error is
invalid_date
Metadata
Metadata
Assignees
Labels
No labels