mirror of https://github.com/requarks/wiki
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
415 B
19 lines
415 B
const gql = require('graphql')
|
|
|
|
module.exports = new gql.GraphQLScalarType({
|
|
name: 'Date',
|
|
description: 'ISO date-time string at UTC',
|
|
parseValue(value) {
|
|
return new Date(value)
|
|
},
|
|
serialize(value) {
|
|
return value.toISOString()
|
|
},
|
|
parseLiteral(ast) {
|
|
if (ast.kind !== gql.Kind.STRING) {
|
|
throw new TypeError('Date value must be an string!')
|
|
}
|
|
return new Date(ast.value)
|
|
}
|
|
})
|