mirror of https://github.com/Requarks/wiki.git
4 changed files with 50 additions and 26 deletions
Split View
Diff Options
-
10server/configure.js
-
4server/modules/graphql.js
-
22server/schemas/scalar-date.js
-
40server/schemas/types.graphql
@ -0,0 +1,22 @@ |
|||
'use strict' |
|||
|
|||
const gql = require('graphql') |
|||
|
|||
module.exports = { |
|||
Date: 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) |
|||
} |
|||
}) |
|||
} |
Write
Preview
Loading…
Cancel
Save