{"id":13499221,"url":"https://github.com/excitement-engineer/graphql-iso-date","last_synced_at":"2025-05-15T09:07:45.191Z","repository":{"id":40790637,"uuid":"64499842","full_name":"excitement-engineer/graphql-iso-date","owner":"excitement-engineer","description":"A set of RFC 3339 compliant date/time GraphQL scalar types.","archived":false,"fork":false,"pushed_at":"2022-12-07T09:20:18.000Z","size":617,"stargazers_count":523,"open_issues_count":33,"forks_count":50,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-09T16:44:24.614Z","etag":null,"topics":["graphql","graphql-js","graphql-scalar"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/excitement-engineer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-29T17:49:34.000Z","updated_at":"2025-04-14T19:43:56.000Z","dependencies_parsed_at":"2023-01-23T16:46:05.503Z","dependency_job_id":null,"html_url":"https://github.com/excitement-engineer/graphql-iso-date","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/excitement-engineer%2Fgraphql-iso-date","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/excitement-engineer%2Fgraphql-iso-date/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/excitement-engineer%2Fgraphql-iso-date/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/excitement-engineer%2Fgraphql-iso-date/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/excitement-engineer","download_url":"https://codeload.github.com/excitement-engineer/graphql-iso-date/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254310515,"owners_count":22049469,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphql","graphql-js","graphql-scalar"],"created_at":"2024-07-31T22:00:30.995Z","updated_at":"2025-05-15T09:07:40.181Z","avatar_url":"https://github.com/excitement-engineer.png","language":"JavaScript","funding_links":[],"categories":["Libraries","JavaScript"],"sub_categories":["JavaScript Libraries"],"readme":"# GraphQL ISO Date\n\n\n\n[![npm version](https://badge.fury.io/js/graphql-iso-date.svg)](http://badge.fury.io/js/graphql-iso-date)\n[![Build Status](https://travis-ci.org/excitement-engineer/graphql-iso-date.svg?branch=master)](https://travis-ci.org/excitement-engineer/graphql-iso-date)\n[![codecov](https://codecov.io/gh/excitement-engineer/graphql-iso-date/branch/master/graph/badge.svg)](https://codecov.io/gh/excitement-engineer/graphql-iso-date)\n\n**NOTICE: The scalars defined in this repository have moved to the [GraphQL-scalars](https://github.com/Urigo/graphql-scalars) repository where they will be maintained.**\n\nGraphQL ISO Date is a set of [RFC 3339](./rfc3339.txt) compliant date/time scalar types to be used with [graphQL.js](https://github.com/graphql/graphql-js).\n\n\u003e RFC 3339 *\"defines a date and time format for use in Internet\nprotocols that is a profile of the ISO 8601 standard for\nrepresentation of dates and times using the Gregorian calendar.\"*\n\n\u003e **Date and Time on the Internet: Timestamps, July 2002.**\n\nA basic understanding of [GraphQL](http://facebook.github.io/graphql/) and of the [graphQL.js](https://github.com/graphql/graphql-js) implementation is needed to provide context for this library.\n\nThis library contains the following scalars:\n\n- `Date`: A date string, such as 2007-12-03.\n- `Time`: A time string at UTC, such as 10:15:30Z\n- `DateTime`: A date-time string at UTC, such as 2007-12-03T10:15:30Z.\n\n## Getting started\n\nInstall `graphql-iso-date` using yarn\n\n```sh\nyarn add graphql-iso-date\n```\n\nOr using npm\n\n```sh\nnpm install --save graphql-iso-date\n```\n\nGraphQL ISO Date exposes 3 different date/time scalars that can be used in combination with [graphQL.js](https://github.com/graphql/graphql-js). Let's build a simple schema using the scalars included in this library and execute a query:\n\n```js\nimport {\n  graphql,\n  GraphQLObjectType,\n  GraphQLSchema,\n} from 'graphql';\n\nimport {\n  GraphQLDate,\n  GraphQLTime,\n  GraphQLDateTime\n} from 'graphql-iso-date';\n\nconst schema = new GraphQLSchema({\n  query: new GraphQLObjectType({\n    name: 'Query',\n    fields: {\n      birthdate: {\n        type: GraphQLDate,\n        //resolver can take a Date or date string.\n        resolve: () =\u003e new Date(1991, 11, 24)\n      },\n      openingNYSE: {\n        type: GraphQLTime,\n        //resolver can take a Date or time string.\n        resolve: () =\u003e new Date(Date.UTC(2017, 0, 10, 14, 30))\n      },\n      instant: {\n        type: GraphQLDateTime,\n        // resolver can take Date, date-time string or Unix timestamp (number).\n        resolve: () =\u003e new Date(Date.UTC(2017, 0, 10, 21, 33, 15, 233))\n      }\n    }\n  })\n});\n\nconst query = `\n  {\n    birthdate\n    openingNYSE\n    instant\n  }\n`;\n\ngraphql(schema, query).then(result =\u003e {\n\n    // Prints\n    // {\n    //   data: {\n    //     birthdate: '1991-12-24',\n    //     openingNYSE: '14:30:00.000Z',\n    //     instant: '2017-01-10T21:33:15.233Z'\n    //   }\n    // }\n    console.log(result);\n});\n```\n\n## Examples\n\nThis 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:\n\n* [returning Date, Time, and DateTime](https://codesandbox.io/s/k9xm5z7223)\n* [taking a Date as a query parameter](https://codesandbox.io/s/m5782nj1w9)\n\nRun the examples by downloading this project and running the following commands:\n\nInstall dependencies using yarn\n\n```sh\nyarn\n```\n\nOr npm\n\n```sh\nnpm install\n```\n\nRun the examples\n\n```\nnpm run examples\n```\n\n## Scalars\n\nThis section provides a detailed description of each of the scalars.\n\n \u003e 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](http://facebook.github.io/graphql/#sec-Scalars).\n\n### Date\n\nA date string, such as 2007-12-03, compliant with the `full-date` format outlined in section 5.6 of the [RFC 3339](./rfc3339.txt) profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar.\n\nThis scalar is a description of the date, as used for birthdays for example. It cannot represent an instant on the time-line.\n\n**Result Coercion**\n\nJavascript Date instances are coerced to an RFC 3339 compliant date string. Invalid Date instances raise a field error.\n\n**Input Coercion**\n\nWhen 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.\n\n### Time\n\nA time string at UTC, such as 10:15:30Z, compliant with the `full-time` format outlined in section 5.6 of the [RFC 3339](./rfc3339.txt) profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar.\n\nThis 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.\n\nThis scalar ignores leap seconds (thereby assuming that a minute constitutes of 59 seconds), in this respect it diverges from the RFC 3339 profile.\n\nWhere 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\".\n\n**Result Coercion**\n\nJavascript Date instances are coerced to an RFC 3339 compliant time string by extracting the UTC time part. Invalid Date instances raise a field error.\n\n**Input Coercion**\n\nWhen 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.\n\n### DateTime\n\nA 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](./rfc3339.txt) profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar.\n\nThis scalar is a description of an exact instant on the time-line such as the instant that a user account was created.\n\nThis scalar ignores leap seconds (thereby assuming that a minute constitutes of 59 seconds). In this respect it diverges from the RFC 3339 profile.\n\nWhere 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\".\n\n**Result Coercion**\n\nJavaScript 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.\n\n**Input Coercion**\n\nWhen 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexcitement-engineer%2Fgraphql-iso-date","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexcitement-engineer%2Fgraphql-iso-date","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexcitement-engineer%2Fgraphql-iso-date/lists"}