Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AccurateDuration and NominalDuration Scalars #132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AlexandreCarlton
Copy link

@AlexandreCarlton AlexandreCarlton commented Mar 16, 2024

This adds support for two scalars:

  • AccurateDuration (which maps to a java.time.Duration).
  • NominalDuration (which maps to a java.time.Period).

Both of these heavily relate to durations as defined in ISO 8601 but with the following caveats:

  • AccurateDuration only relates to the portion of a duration that is context-free (i.e. does not need to know the calendar position to determine its value). It maps to a java.time.Duration.

  • NominalDuration relates to the portion of a duration that is dependent on knowing the calendar position to determine its value. It maps to a java.time.Period.

The naming of these are strongly influenced by the wording in ISO 8601:

Duration can be expressed by a combination of components with accurate
duration (hour, minute and second) and components with nominal duration
(year, month, week and day).

The code here follows the same pattern as that used for the DateTime Scalar.

Please see graphql/graphql-scalars#24 for the specification of AccurateDuration and NominalDuration.

This adds support for two scalars:

 - `AccurateDuration` (which maps to a `java.time.Duration`).
 - `NominalDuration` (which maps to a `java.time.Period`).

Both of these heavily relate to durations as defined in ISO 8601 but
with the following caveats:

- `AccurateDuration` only relates to the portion of a duration that is
  context-free (i.e. does not need to know the calendar position to
  determine its value). It maps to a `java.time.Duration`.

- `NominalDuration` relates to the portion of a duration that is
  dependent on knowing the calendar position to determine its value. It
  maps to a `java.time.Period`.

The naming of these are strongly influenced by the wording in ISO 8601:

> Duration can be expressed by a combination of components with accurate
  duration (hour, minute and second) and components with nominal duration
  (year, month, week and day).

The code here follows the same pattern as that used for the `DateTime`
Scalar.
AlexandreCarlton added a commit to AlexandreCarlton/graphql-scalars that referenced this pull request Mar 16, 2024
This pull request attempts to document two different types of
Durations per the ISO 8601 standard:

 - `AccurateDuration`, relating to the portion of a Duration that is
   context-free (that is, it only contains seconds, minutes, hours, and
   24-hour days).

 - `NominalDuration`, relating ot the portion that is dependent on the
   position in the calendar with respect to which the duration is being
   evaluated. It contains calendar years, months, weeks and days.

Please see graphql-java/graphql-java-extended-scalars#132
for the implementation in `graphql-java`.
AlexandreCarlton added a commit to AlexandreCarlton/graphql-scalars that referenced this pull request Mar 16, 2024
This pull request attempts to document two different types of
Durations per the ISO 8601 standard:

 - `AccurateDuration`, relating to the portion of a Duration that is
   context-free (that is, it only contains seconds, minutes, hours, and
   24-hour days).

 - `NominalDuration`, relating ot the portion that is dependent on the
   position in the calendar with respect to which the duration is being
   evaluated. It contains calendar years, months, weeks and days.

Please see graphql-java/graphql-java-extended-scalars#132
for the implementation in `graphql-java`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant