Skip to content

Error when outputting a leap day date with ISO8601Date type #5311

Closed
@jeefujee

Description

@jeefujee

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions