Boolean
True or false scalar type
Audience: Programmer
The Boolean scalar type represents true or false.
Format
Only two possible values:
trueorfalseNot nullable when defined as
Boolean!Case-sensitive (lowercase only)
Usage
type InventoryItem {
id: ID!
isActive: Boolean!
isDeleted: Boolean!
hasStock: Boolean
}
query {
inventoryItems(
where: {
isActive: true
isDeleted: false
}
) {
edges {
node {
id
hasStock
}
}
}
}Common Boolean Fields
Status flags (
isActive,isDeleted,isEnabled)Feature toggles (
hasFeatureX,canDoY)Existence checks (
hasChildren,isEmpty)Permissions (
canEdit,canDelete)State indicators (
isLoading,isComplete)
Filtering
Boolean fields in where clauses:
Best Practices
Use clear, positive names when possible (
isActivevsisInactive)Consider nullable booleans for tri-state logic
Document the default value
Use for binary states only
See Also
Input Types - Boolean filters in where clauses
Types - Types using boolean fields
Last updated
Was this helpful?
