UNPKG

664 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const graphql_1 = require("graphql");
4exports.GraphQLISODateTime = new graphql_1.GraphQLScalarType({
5 name: "DateTime",
6 description: "The javascript `Date` as string. Type represents date and time as the ISO Date string.",
7 parseValue(value) {
8 return new Date(value);
9 },
10 serialize(value) {
11 if (value instanceof Date) {
12 return value.toISOString();
13 }
14 return null;
15 },
16 parseLiteral(ast) {
17 if (ast.kind === graphql_1.Kind.STRING) {
18 return new Date(ast.value);
19 }
20 return null;
21 },
22});