Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field hooks beforeOperation and afterOperation not running with default value #9382

Open
stentibbing opened this issue Oct 29, 2024 · 0 comments

Comments

@stentibbing
Copy link

stentibbing commented Oct 29, 2024

To reproduce:

  1. 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,
  },
});
  1. Create new entity, without changing the default value
  2. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant