keystone
keystone copied to clipboard
Field hooks beforeOperation and afterOperation not running with default value
To reproduce:
- Create new Keystone app with the following config:
import { config, list } from "@keystone-6/core";
import { allowAll } from "@keystone-6/core/access";
import { text, integer } from "@keystone-6/core/fields";
import { session } from "./auth";
export default config({
db: {
provider: "sqlite",
url: "file:./keystone.db",
},
lists: {
Material: list({
access: allowAll,
fields: {
name: text({ validation: { isRequired: true }, isIndexed: "unique" }),
order: integer({
validation: {
isRequired: false,
min: 1,
},
defaultValue: 1,
hooks: {
resolveInput: async () => console.log("resolveInput"),
beforeOperation: async () => console.log("beforeOperation"),
},
}),
},
}),
},
session,
ui: {
isAccessAllowed: () => true,
},
});
- Create new entity, without changing the default value
- Observe the stdout having only "resolveInput" being logged
Note: If the value of order field is different from default value, the hooks are firing as expected
Expectation:
Fields with default values should not behave any different from fields with default values.
Using: node 20.18.0 keystone-6/core 6.3.0