Uniforms: Material: GraphQL type Boolean! (non nullable bool) combined with noValidate={false} (using browser's validation) makes checkbox required = you have to set the checkbox to 'true'

Created on 9 Jan 2021  路  2Comments  路  Source: vazco/uniforms

Hi and thanks for a cool project.

This bug is for uniforms-material

When usingnoValidate={false} on the AutoForm(which will use the browser's validation), combined with GraphQL type Boolean! (non nullable boolean) makes the checkbox required, which means you have to click the checkbox and set the value to true.

_I think this is wrong_, you should still be able to have a false value, just not null.
https://stackoverflow.com/questions/57013591/can-we-return-null-for-a-boolean-value-in-graphql-response#:~:text=To%20declare%20a%20type%20that,type%20or%20an%20object%20type.

To test for your self, submit the form without checking the checkbox:
https://codesandbox.io/s/uniforms-codesandbox-forked-ep23q?file=/src/schema/graphql-schema/index.js

Couldn't figure out where in the code this i done, otherwise I could made a PR

question

All 2 comments

Hi @al222cv. You could add { isAwesome: { required: false } } to your bridge (3rd parameter) to make it optional for uniforms alone. While this allows submitting unchecked checkbox, it also hides required styling (e.g., a red star in uniforms-semantic), but this seems fine, as it's not supposed to be required anyway. Let us know, whether it works for you.

@radekmie Aha thanks for the answer. It works perfectly, so not an issue anymore. :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Vandell63 picture Vandell63  路  3Comments

simplecommerce picture simplecommerce  路  6Comments

wtrocki picture wtrocki  路  7Comments

dacioromero picture dacioromero  路  5Comments

LordA98 picture LordA98  路  5Comments