Repository navigation
Conversation
- Keep each date’s precision (year, month, day or dateTime) in a stored,
unindexed <field>_precision companion beside its Unix seconds
- Parse dates without Date’s string parser: a year, month or day ignores its
timezone, a date-time without one is read as UTC, and 24:00:00 and offsets
up to ±14:00 are accepted
- Serve each value in one canonical form per precision (1999, 1999-05,
1999-05-03, 1999-05-03T12:30:00Z); serve a range facet’s extent and buckets
as date-times
- Fetch the companion with a lookup’s fields, and reserve its name against
declared fields
BREAKING CHANGE: GraphQL date fields come back at their source’s precision
rather than as a millisecond timestamp: 1999 instead of
1999-01-01T00:00:00.000Z, and date-times as 1999-05-03T12:30:00Z.
isoToUnixSeconds returns { seconds, precision } instead of a number,
unixSecondsToIso takes a required precision, and a date’s SearchValue is a
StoredDate instead of a number. Reindex to fill the companion; until then
dates are served as date-times.
- Type date fields, DateExtent bounds and DateRange bounds as ISO8601Date, specified by the dates section of the docs - Serve an unbinned date facet's buckets as DateBucket, so a bucket value feeds straight into DateRange - Reject an unreadable date bound at coercion with BAD_USER_INPUT - Document the ISO 8601 agreement the scalar follows BREAKING CHANGE: date fields, DateExtent, DateRange bounds and date facet buckets are typed ISO8601Date instead of String, and date buckets are DateBucket instead of ValueBucket. Declare variables as ISO8601Date and select DateBucket where you selected ValueBucket.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A
datefield now comes back at the precision its source gave, in one canonical form per precision:19991999-01-01T00:00:00.000Z19991999-051999-05-01T00:00:00.000Z1999-051999-05-03+02:001999-05-031999+02:001999-01-01T00:46:48.000Z19991999-05-03T14:30:00+02:001999-05-03T12:30:00.000Z1999-05-03T12:30:00Z1999-05-03T14:30:00(Amsterdam host)12:30Z1999-05-03T14:30:00ZisoToUnixSecondsreturns{ seconds, precision }and parses dates withoutDate’s string parser. A year, month or day ignores its timezone and is stored at its first second in UTC. A date-time without a timezone is read as UTC.24:00:00and offsets up to ±14:00 are accepted, as in XSD.unixSecondsToIsotakes the precision to format at.<field>_precisioncompanion (PhysicalFields.precision), at top level and in nested objects. Sorting and filtering still read the seconds alone.validateSearchTypereserves the companion’s name.SearchValueis now aStoredDate. The Typesense adapter reconstructs it from the companion, and lookups fetch the companion along with the date. An index without the companion reportsdateTime, so dates keep being served as date-times until a reindex.An
ISO8601DatescalarEvery date on the GraphQL surface was a plain
String. It is now anISO8601Date, a custom scalar whose@specifiedByURL points at a new Dates section in the docs. That section gives the four forms and states the agreement ISO 8601 asks for: years beyond four digits, reduced precision, year 0 as 1 BCE, citing XSD 1.1 Part 2.DateExtentbounds andDateRangebounds. An unbinned date facet’s buckets get their ownDateBucket(value and count), sinceValueBucket.valuestaysString.BAD_USER_INPUT, asIRIdoes, instead of reachingvalidateQuery.Date: codegen commonly mapsDateto a JSDate, which cannot hold a deep-time year, and graphql-scalars’Datemeans a full date only.RangeBucketwithFloatbounds in Unix seconds, as before. That is left for a follow-up.Deviation from the issue: facets stay date-times
The issue asks for a range facet’s extent and buckets to be formatted at the coarsest precision stored for the field. This PR leaves that out: they are served as date-times, and the UI picks the grain it draws at.
1999and1999-05-03would both read1999.So the companion is never faceted, and the mixed-precision facet test from “Done when” does not apply.
Coarse upper bounds (
max: "1999"still means the first second of 1999) stay out of scope, as the issue says. The docs state the workaround.Fix #973
Fix #980