n
11/03/2021, 10:28 AMRyan
11/03/2021, 10:59 AMn
11/03/2021, 11:01 AMn
11/03/2021, 11:01 AMdateOfBirth: "2021-11-03"
Ryan
11/03/2021, 11:04 AM2021-11-03T00:00:00.000Z
.n
11/03/2021, 11:12 AMn
11/03/2021, 11:13 AMdateOfBirth: Date
in typescript
then it's throwing:
Argument dateOfBirth: Got invalid value null on prisma.createOneBeneficialOwner. Provided null, expected DateTime.
Ryan
11/03/2021, 11:20 AMnull
.n
11/03/2021, 11:22 AMDate
which if it's not Date
it will return nulln
11/03/2021, 11:23 AMDate
it will resolve as yyyy-mm-dd
etc vs the timestamp will break the strict type of Date
n
11/03/2021, 11:23 AMDateTime
on the prisma siden
11/03/2021, 11:23 AMDateTime
with @db.date
Ryan
11/03/2021, 11:28 AMDate
object or the ISO string. So you would need to have the DateTime
scalar setup in GraphQLn
11/03/2021, 10:24 PMimport {
CustomScalar,
Scalar,
} from '@nestjs/graphql';
import { Kind } from 'graphql';
@Scalar('Date', () => Date)
export class DateScalar implements CustomScalar<string, Date> {
public description = 'Date custom scalar type';
public parseValue(value: string): Date {
return new Date(value); // value from the client
}
public serialize(value: Date): string {
return new Date(value).toISOString(); // value sent to the client
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/explicit-module-boundary-types
public parseLiteral(ast: any): any {
if (ast.kind === <http://Kind.INT|Kind.INT>) {
return new Date(ast.value);
}
return new Date(ast.value).toISOString();
}
}