UNPKG

@nestjs/graphql

Version:

Nest - modern, fast, powerful node.js web framework (@graphql)

15 lines (14 loc) 510 B
import { GraphQLScalarType, Kind } from 'graphql'; export const GraphQLISODateTime = new GraphQLScalarType({ name: 'DateTime', description: 'A date-time string at UTC, such as 2019-12-03T09:54:33Z, compliant with the date-time format.', parseValue(value) { return new Date(value); }, serialize(value) { return value instanceof Date ? value.toISOString() : null; }, parseLiteral(ast) { return ast.kind === Kind.STRING ? new Date(ast.value) : null; }, });