import { CustomScalar , Scalar } from '@nestjs/graphql' ; import { Kind , ValueNode } from 'graphql' ; @ Scalar ( 'Date' , ( ) => Date ) export class DateScalar implements CustomScalar < number , Date > { public description : string = 'Date custom scalar type' ; public parseValue ( value ) { return new Date ( value ) ; } public serialize ( value ) { return value . getTime ( ) ; } public parseLiteral ( ast ) { if ( ast . kind === Kind . INT ) { return new Date ( ast . value ) ; } return null ; } }