Boolean

True or false scalar type

Audience: Programmer

The Boolean scalar type represents true or false.

Format

  • Only two possible values: true or false

  • Not 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

  1. Use clear, positive names when possible (isActive vs isInactive)

  2. Consider nullable booleans for tri-state logic

  3. Document the default value

  4. Use for binary states only

See Also

  • Input Types - Boolean filters in where clauses

  • Types - Types using boolean fields

Last updated

Was this helpful?