Custom Date Type for GraphQL
This is a custom date type implementation for GraphQL. GraphQL does not contain a native date type but it does allow you to specify custom scalar types that serializes to strings, or other scalar types, but conforms to certain standards.
To use this type you in your GraphQL schema you simply install this module with
npm install --save graphql-custom-datetype and use it. In the minimal example
below we expose the query
now that simply returns the current date and time.
// examples/now.js;;let schema =query:name: 'Query'fields:now:type: CustomGraphQLDateType// Resolve fields with the custom date type to a valid Date object;;
Running this prints the current date:
$ babel-node examples/now.js