You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m guessing not all the mutation lifecycles are executed on createItems.
Describe the bug
When using createItems on a field with a default values (with our without required) the default value is not applied.
With Knex it gives: I get Error: null value in column “comment” violates not-null constraint. With Mongoose, it creates the item without a default value.
To Reproduce
Steps to reproduce the behaviour. Please provide code snippets or a repository:
npm init keystone-app my-app
Select the Start with Auth
Add bugField to fields of user:
keystone.createList("User", {
fields: {
name: { type: Text },
email: {
type: Text,
isUnique: true,
},
isAdmin: {
type: Checkbox,
// Field-level access controls
// Here, we set more restrictive field access so a non-admin cannot make themselves admin.
access: {
update: access.userIsAdmin,
},
},
password: {
type: Password,
},
bugField: {
required: true,
type: Text,
defaultValue: "test",
},
},
// List-level access controls
access: {
read: access.userIsAdminOrOwner,
update: access.userIsAdminOrOwner,
create: access.userIsAdmin,
delete: access.userIsAdmin,
auth: true,
},
});
You will see that with mongoose you will get two users. the first was the one with the executeQuery which has a default bugField. You will see Bill does not have a default bugField. Adding or removing required makes no difference.
Expected behaviour
All lifecycles are executed, including default fields.
Bill should have a bugField that contains the value test.
Screenshots
If applicable, add screenshots to help explain your problem.
Yes that is correct not all the lifecycle events are connected to createItems. For that use executeQuery. createItems is not meant to be relied upon for seeding production data and is more a stop-gap for getting initial data into demo.
I'm going to create a task for myself to update all the demos and docs to help avoid this until createItems can be removed: #1091
Bug report
I’m guessing not all the mutation lifecycles are executed on createItems.
Describe the bug
When using createItems on a field with a default values (with our without required) the default value is not applied.
With Knex it gives: I get Error: null value in column “comment” violates not-null constraint. With Mongoose, it creates the item without a default value.
To Reproduce
Steps to reproduce the behaviour. Please provide code snippets or a repository:
npm init keystone-app my-app
Select the Start with Auth
Add bugField to fields of user:
In initial data add:
You will see that with mongoose you will get two users. the first was the one with the
executeQuery
which has a default bugField. You will see Bill does not have a defaultbugField
. Adding or removing required makes no difference.Expected behaviour
All lifecycles are executed, including default fields.
Bill should have a bugField that contains the value
test
.Screenshots
If applicable, add screenshots to help explain your problem.
System information
MacOS
"@keystonejs/adapter-mongoose": "^8.1.0",
"@keystonejs/app-admin-ui": "^6.0.0",
"@keystonejs/app-graphql": "^5.1.7",
"@keystonejs/auth-password": "^5.1.7",
"@keystonejs/fields": "^10.0.0",
"@keystonejs/keystone": "^9.0.0",
The text was updated successfully, but these errors were encountered: