Boolean field defaults: `null` vs `false`?

On boolean fields, is it possible to configure the default value to be false instead of null if it’s never been touched?

For example, these fields:

Using the query:

query SimpleQuery {
  allAlerts {
    sitewide
    overrideHours
    events
  }
}

Returns:

  "data": {
    "allAlerts": [
      {
        "sitewide": true,
        "overrideHours": true,
        "events": true
      },
      {
        "sitewide": true,
        "overrideHours": false,
        "events": true
      },
      {
        "sitewide": null,
        "overrideHours": null,
        "events": null
      }
    ]
  }
}

The 2nd overrideHours is false because someone toggled it, but the 3rd is null even though the field default value is set:

With Javascript, truthiness is a weird and confusing topic and having the API typecast booleans (or perhaps fail to, in cases where it isn’t set by a user) results in different possible responses for that field.

Might it be possible to implement this in a non-breaking way? Perhaps by adding a “required” validation for booleans, in which case non-required, unfilled fields would still return null as before, but required booleans will return false instead?

Or is there a better way to deal with this? Should I just implicitly convert from null to false on the client side?

hey @roger this has proven controversial already :frowning: I’ll make this a feature request and as soon as we get some votes we’ll consider for development

Yeah, I imagine it’s not an easy decision! Thanks for considering it.

We can work around it for now, no problem :slight_smile: