Gathering detailed insights and metrics for graphql-iso-date
Gathering detailed insights and metrics for graphql-iso-date
Gathering detailed insights and metrics for graphql-iso-date
Gathering detailed insights and metrics for graphql-iso-date
A set of RFC 3339 compliant date/time GraphQL scalar types.
npm install graphql-iso-date
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
523 Stars
121 Commits
50 Forks
8 Watching
39 Branches
6 Contributors
Updated on 24 Nov 2024
JavaScript (98.8%)
Shell (1.2%)
Cumulative downloads
Total Downloads
Last day
12.7%
22,127
Compared to previous day
Last week
3.8%
116,887
Compared to previous week
Last month
4%
464,537
Compared to previous month
Last year
-3.6%
7,078,214
Compared to previous year
1
NOTICE: The scalars defined in this repository have moved to the GraphQL-scalars repository where they will be maintained.
GraphQL ISO Date is a set of RFC 3339 compliant date/time scalar types to be used with graphQL.js.
RFC 3339 "defines a date and time format for use in Internet protocols that is a profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar."
Date and Time on the Internet: Timestamps, July 2002.
A basic understanding of GraphQL and of the graphQL.js implementation is needed to provide context for this library.
This library contains the following scalars:
Date
: A date string, such as 2007-12-03.Time
: A time string at UTC, such as 10:15:30ZDateTime
: A date-time string at UTC, such as 2007-12-03T10:15:30Z.Install graphql-iso-date
using yarn
1yarn add graphql-iso-date
Or using npm
1npm install --save graphql-iso-date
GraphQL ISO Date exposes 3 different date/time scalars that can be used in combination with graphQL.js. Let's build a simple schema using the scalars included in this library and execute a query:
1import { 2 graphql, 3 GraphQLObjectType, 4 GraphQLSchema, 5} from 'graphql'; 6 7import { 8 GraphQLDate, 9 GraphQLTime, 10 GraphQLDateTime 11} from 'graphql-iso-date'; 12 13const schema = new GraphQLSchema({ 14 query: new GraphQLObjectType({ 15 name: 'Query', 16 fields: { 17 birthdate: { 18 type: GraphQLDate, 19 //resolver can take a Date or date string. 20 resolve: () => new Date(1991, 11, 24) 21 }, 22 openingNYSE: { 23 type: GraphQLTime, 24 //resolver can take a Date or time string. 25 resolve: () => new Date(Date.UTC(2017, 0, 10, 14, 30)) 26 }, 27 instant: { 28 type: GraphQLDateTime, 29 // resolver can take Date, date-time string or Unix timestamp (number). 30 resolve: () => new Date(Date.UTC(2017, 0, 10, 21, 33, 15, 233)) 31 } 32 } 33 }) 34}); 35 36const query = ` 37 { 38 birthdate 39 openingNYSE 40 instant 41 } 42`; 43 44graphql(schema, query).then(result => { 45 46 // Prints 47 // { 48 // data: { 49 // birthdate: '1991-12-24', 50 // openingNYSE: '14:30:00.000Z', 51 // instant: '2017-01-10T21:33:15.233Z' 52 // } 53 // } 54 console.log(result); 55});
This project includes several examples in the folder /examples
explaining how to use the various scalars. You can also see some live editable examples on Launchpad:
Run the examples by downloading this project and running the following commands:
Install dependencies using yarn
1yarn
Or npm
1npm install
Run the examples
npm run examples
This section provides a detailed description of each of the scalars.
A reference is made to
coercion
in the description below. For further clarification on the meaning of this term, please refer to the GraphQL spec.
A date string, such as 2007-12-03, compliant with the full-date
format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar.
This scalar is a description of the date, as used for birthdays for example. It cannot represent an instant on the time-line.
Result Coercion
Javascript Date instances are coerced to an RFC 3339 compliant date string. Invalid Date instances raise a field error.
Input Coercion
When expected as an input type, only RFC 3339 compliant date strings are accepted. All other input values raise a query error indicating an incorrect type.
A time string at UTC, such as 10:15:30Z, compliant with the full-time
format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar.
This scalar is a description of a time instant such as the opening bell of the New York Stock Exchange for example. It cannot represent an exact instant on the time-line.
This scalar ignores leap seconds (thereby assuming that a minute constitutes of 59 seconds), in this respect it diverges from the RFC 3339 profile.
Where an RFC 3339 compliant time string has a time-zone other than UTC, it is shifted to UTC. For example, the time string "14:10:20+01:00" is shifted to "13:10:20Z".
Result Coercion
Javascript Date instances are coerced to an RFC 3339 compliant time string by extracting the UTC time part. Invalid Date instances raise a field error.
Input Coercion
When expected as an input type, only RFC 3339 compliant time strings are accepted. All other input values raise a query error indicating an incorrect type.
A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the date-time
format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar.
This scalar is a description of an exact instant on the time-line such as the instant that a user account was created.
This scalar ignores leap seconds (thereby assuming that a minute constitutes of 59 seconds). In this respect it diverges from the RFC 3339 profile.
Where an RFC 3339 compliant date-time string has a time-zone other than UTC, it is shifted to UTC. For example, the date-time string "2016-01-01T14:10:20+01:00" is shifted to "2016-01-01T13:10:20Z".
Result Coercion
JavaScript Date instances and Unix timestamps (represented as 32-bit signed integers) are coerced to RFC 3339 compliant date-time strings. Invalid Date instances raise a field error.
Input Coercion
When expected as an input type, only RFC 3339 compliant date-time strings are accepted. All other input values raise a query error indicating an incorrect type.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 3/30 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
78 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More