keystone
keystone copied to clipboard
Type of `resolvedData` in hooks should use Prisma create/update types
Define a user list like this:
export const User = list({
fields: {
email: text({
isIndexed: 'unique',
validation: { isRequired: true },
}),
password: password(),
firstName: text(),
lastName: text(),
dob: timestamp(),
},
hooks: {
async afterOperation({ resolvedData }) {
...
},
},
});
In the afterOperation hook, resolvedData is typed as UserUpdateInput:
export type UserUpdateInput = {
readonly email?: Scalars["String"] | null;
readonly password?: Scalars["String"] | null;
readonly firstName?: Scalars["String"] | null;
readonly lastName?: Scalars["String"] | null;
readonly dob?: any | null;
};
However, according to the prisma type, email, firstName, lastName should be non-nullable:
export type User = {
id: string
email: string
password: string | null
firstName: string
lastName: string
dob: Date | null
}