It's recommended you connect your own database to Grafbase and define the schema for it to generate queries and mutations.

Grafbase provides a simple yet flexible and scalable database that you build using schema, and manage using a intuitive UI.

The database is low latency, serverless, multi-region and deploys instantly with zero downtime.

Grafbase automatically generates queries to fetch by ID, unique value, or a collection as well as all the necessary mutations to create, update, delete, link, and unlink data.

The schema file describes the shape of your data, relations, and configuration for validations and auth using the GraphQL schema definition language.

This database can be used by itself or together with other Grafbase features.

Grafbase automatically generates a CRUD API for models specified inside of your project's config.

import { config, g } from '@grafbase/sdk'

g.model('Post', {
  title: g.string(),
  slug: g.string().unique(),
  published: g.boolean().optional().default(false),
  rating: g.float().optional(),

export default config({
  schema: g

You can also create regular object types that can be embedded inside of your existing models:

import { config, g } from '@grafbase/sdk'

const address = g.type('Address', {
  line1: g.string(),
  line2: g.string().optional(),
  zip: g.string().optional(),
  phone: g.phoneNumber().optional()

g.model('Order', {
  billingAddress: g.ref(address).optional(),
  shippingAddress: g.ref(address).optional()

export default config({
  schema: g

Grafbase automatically manages system fields for any model — id, createdAt, updatedAt.

Models support many different field types.

  • Grafbase does not currently support Interface or Union types.
Was this page helpful?