Default values

Grafbase supports default values for model fields.

import { g } from '@grafbase/sdk'

const status = g.enum('Status', ['PENDING_REVIEW', 'APPROVED'])

g.model('Review', {
  rating: g.int().default(5),
  published: g.boolean().default(false),
  status: g.enumRef(status).default('PENDING_REVIEW')
})

The default value must be of the same type as the field specified.

Was this page helpful?