The Postgres connector allows you to connect one or more Postgres databases to Grafbase, and instantly generate a GraphQL API for all tables.

The Postgres connector accepts the following config:

  • name (required) — The unique name for the data source
  • url (required) — The connection string used for your Postgres database
import { config, connector, g } from '@grafbase/sdk'

const pg = connector.Postgres('Postgres', {
  url: g.env('DATABASE_URL'),


export default config({
  schema: g,

Grafbase automatically generates a GraphQL API to read and write to your Postgres database using the tables it found during the introspection of your database on startup.

Was this page helpful?