Jonathan Marbutt
02/09/2022, 9:06 PMDateTime? @db.Timestamp(6)
Andrew Ross
02/09/2022, 11:18 PMgraphql-scalars
and @types/graphql-scalars
in your entity/object defs for your models
so for phoneNumber, for example, I use
PhoneNumberResolver
which throws an error if a phone number field doesn't conform to the international standard E144 format (basically just a "+"-sign with the countrycode before a phone number)
so <tel:+18885551234|+18885551234>
would be accepted, but 18885551234
would throw an error
it resolves to a PhoneNumberScalar
type in the schema
same thing applies to ISO-8601 International Time format--I believe it is called a TimeResolver
in the graphql-scalars package
a hacky workaround for getting ISO-8601 starting with a full datetime string would be
const getTimestamp = new Date(Date.now()).toISOString();
console.log(getTimestamp)
const getDateOnly = getTimestamp.split(/([T])/)[0];
// the "T" character is at index 1 of this split datetime string
// "2022-02-09T23:13:22.620Z": [0] 2022-02-09 | [1] T | [2] 23:13:22.620Z
const getTimeOnly = getTimestamp.split(/([T])/)[2];
console.log(JSON.stringify({
isoDate: getDateOnly,
isoTime: getTimeOnly
}, null, 2))
// don't want the TZ appended on the end?
const removeTrailingTZCharacter = getTimeOnly.split(/([Z])/)[0];
// outputs [0] 23:13:22.620 (the Z is at index 1)
console.log(removeTrailingTZCharacter);
Andrew Ross
02/09/2022, 11:22 PM@db.generated("")
approach -- I think it's Timestamp(3) in Postgres...not sure about other databasesJonathan Marbutt
02/09/2022, 11:50 PM@db.generated("")
Jonathan Marbutt
02/09/2022, 11:56 PMUnable to match input value to any allowed input type for the field. Parse errors: [Query parsing/validation error at `Mutation.createOneaccount.data.accountCreateInput.version`: A value is required but not set., Query parsing/validation error at `Mutation.createOneaccount.data.accountUncheckedCreateInput.version`: A value is required but not set.]
Jonathan Marbutt
02/09/2022, 11:56 PM_DateTime_? @db.Timestamp(_6_) @default(dbgenerated())
Jonathan Marbutt
02/09/2022, 11:56 PMdb pull
on a postgres database