Urigo / graphql-scalars

A library of custom GraphQL Scalars for creating precise type-safe GraphQL schemas.
https://www.the-guild.dev/graphql/scalars
MIT License
1.87k stars 133 forks source link

Several issues with the ISO-8601 date/time parser #2323

Closed benwilber closed 3 months ago

benwilber commented 5 months ago

The T separator is just convention. It can be any single character.

https://github.com/Urigo/graphql-scalars/blob/master/src/scalars/iso-date/formatter.ts#L21

Parsing milliseconds with this regex is not allowing comma , separator, only dot .

https://github.com/Urigo/graphql-scalars/blob/master/src/scalars/iso-date/formatter.ts#L49

It also doesn't appear to handle 2-digit timezones. ie +00 instead of +0000

Postgres default timestamptz formatter returns strings like 2024-04-01 01:00:00,000+00

So this library will fail to parse that in at least 3 different ways, even though it's perfectly valid ISO-8601 format.