feat: add support for LocalDate
and LocalTime
scalars
#533
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ref: #480, #531
This PR adds support for two new scalars -
LocalDate
andLocalTime
- that represent dates and times with no associated timezone. They mimic the Java classes of the same name - LocalDate and LocalTime.The scalar values are intentionally NOT serialized into JS
Date
objects on the backend as a signal to resolvers that they must apply thoughtful handling to the value so as not to accidentally apply any TZ offset to the value like what might happen when serializing and deserializing from a JSDate
object.One potential point of contention is that
24:00
is treated as a valid time in theLocalTime
scalar. My project needs to use theLocalTime
scalar to represent the exclusive end time of a time block, and so we need to support24:00
as a signal that a block ends on midnight at the end of a day. For what it's worth, the ISO 8601 spec also allowed24:00
as a valid time for the same reason, at least up until a 2019 revision of the spec:https://en.wikipedia.org/wiki/ISO_8601#Times
Also worth noting is that this PR adds a dependency on the
luxon
library for validating that the provided dates and times are actually valid dates and times, e.g., not things like25:99:99
or2020-13-45
. This resulted in a size increase of the final build and a need to raise themaxSize
of the final bundle to something larger than90kb
. I didn't think this was a huge deal seeing that the project is only used in backend GraphQL server implementations AFAIK.