Keystone js 6 does not allow me to add checkbox field, that looks the following way
// checkbox_field: checkbox({ label: 'Checkbox Field', access: { read: ()=> true, update: ()=> true } }),
I assume it's because I have some null values in db, since I had a the same problem with text type field, which was easily solved using db.isNullable === true. However, I can't find a similar option for checkbox field type.
I tried using defaultValue option and db.map, but it didn't help
In what way does Keystone "not allow" this? Do you get an error? It's difficult to help with a problem without concrete information about what's happening.
I've added the field config you supplied to my local copy of the task manager example without issue.
I've set
db.useMigrations
totrue
so when I restart the app, I'm prompted to create and name a migration that will add the column. The resultant SQL is below. This is for PostgreSQL but it should be for the other DB providers.This will add a non-nullable column to the DB with the default value applied to any existing records (so there shouldn't be anything "blocking" this migration from applying).
For simplicity's sake the Keystone Checkbox field type doesn't support the DB field itself being nullable though it does give you some options to control the nullability of the GraphQL types, ie:
graphql.read.isNonNull
andgraphql.create.isNonNull
. This allows for use cases where a value may be returned asnull
due to access control, or passed in asnull
for a create but saved with a value due to a default value or hook being configured.