We're excited to announce support for PostgreSQL in Grafbase Extensions, bringing even more power, flexibility, and scalability to federated GraphQL APIs.
With this launch, you can now declaratively integrate Postgres databases directly into your federated GraphQL API. That means no subgraph infrastructure, no manual stitching, and no extra services required. It's all managed natively within the Grafbase platform.
Grafbase Extensions let you customize and extend your federated GraphQL API without the need for subgraph infrastructure. Extensions accelerate GraphQL Federation adoption by making it easy to integrate services like databases, authentication, and storage declaratively within your schema.
Think of Extensions as modular building blocks you can attach to your GraphQL API without setting up additional infrastructure manually.
Each extension is:
- Secure WebAssembly modules - sandboxed and isolated within the Grafbase Gateway
- Composable logic - integrated natively into your API without custom stitching
- Portable configuration - version-controlled alongside your project code
Previously, we have launched extensions like gRPC, NATS, and Snowflake - which are all available on the Grafbase Extensions Marketplace.
Now we're introducing the first relational database extension built for Federation: Postgres.
Why Postgres?
Postgres is the gold standard for modern, reliable relational databases:
- Fully open-source
- ACID-compliant transactions
- Powerful querying and indexing
- Extensible ecosystem (e.g., PostGIS, full-text search, JSONB support)
By offering Postgres as a native Grafbase extension, you can now:
- Add a database to your project in seconds.
- Query your database securely from your GraphQL API.
- Scale your backend without worrying about database operations.
Our Postgres extension consists of two powerful components: a Grafbase CLI plugin for database introspection and a WebAssembly module that handles queries at runtime.
First, install the Grafbase CLI:
curl -fsSL https://grafbase.com/downloads/gateway | bash
Then, install the Grafbase Postgres CLI plugin:
curl -fsSL https://raw.githubusercontent.com/grafbase/extensions/refs/heads/main/cli/postgres/install.sh | bash
Create a grafbase-postgres.toml
configuration file in your project:
# Change this to reflect the version of the extension you want to use.
extension_url = "https://grafbase.com/extensions/postgres/0.4.7"
# The generated SDL needs to know in which schema the type comes from.
# If the schema name is not written in the schema, we use this value.
default_schema = "public"
# The name of the database in the Grafbase configuration.
database_name = "default"
Next, introspect your database and generate a GraphQL schema:
grafbase postgres \
--database-url "postgres://postgres:grafbase@localhost:5432/postgres" \
introspect > schema.graphql
This command generates a schema.graphql
file that maps your SQL schema to GraphQL types. Now create a grafbase.toml
file to configure the extension and subgraph:
[extensions.postgres]
# Change to the latest version.
version = "0.4.7"
[[extensions.postgres.config.databases]]
name = "default" # This must match the name in the grafbase-postgres.toml
url = "postgres://postgres:grafbase@localhost:5432/postgres"
[subgraphs.postgres]
schema_path = "./schema.graphql"
Launch the development server to test your new API:
grafbase dev
After confirming everything works locally, install the Grafbase Gateway:
curl -fsSL https://grafbase.com/downloads/gateway | bash
Create a new federated graph in the Grafbase Dashboard and publish your schema as a virtual subgraph:
# Login needs to happen only once.
grafbase login
grafbase publish \
--name postgres \
my-org/my-graph@branch \
-m "initial publish" \
--virtual
Create a new organization level access token in the Grafbase Dashboard, and start the Grafbase Gateway:
export GRAFBASE_ACCESS_TOKEN=<your_access_token>
grafbase-gateway --graph my-graph@branch --config grafbase.toml
The magic happens behind the scenes - your virtual subgraph doesn't need a URL because the Gateway and extension work together to resolve GraphQL operations directly against your Postgres database without any external service calls.
Postgres extension exposes entities automatically! `@key` is added by detecting the primary key of the introspected tables. It is also our first extension making use of our early work on the Composite Schemas specification. Instead of relying on the hidden `_entities` field, we generate dedicated fields to retrieve entities in batch which we identify with the `@lookup` directive. Stay tuned as we open up GraphQL federation beyond dedicated subgraphs!
- Zero infrastructure management: No servers to provision or scaling headaches. Focus on your API and data, Grafbase handles the rest.
- Declarative configuration: Define your Postgres extension alongside your schema and project configuration. Manage everything as code without custom tooling or orchestration.
- CLI-powered schema generation: Use the Grafbase Postgres CLI to introspect your database and instantly generate a GraphQL schema - making it easier than ever to connect relational data to your federated API.
- Secure, isolated, and fast: Databases are deployed in isolated, secure environments optimized for performance and reliability.
- Building new SaaS applications with GraphQL-first and relational data models
- Adding a persistent store to serverless backends with minimal setup
- Rapid prototyping with real databases (no local Postgres instance needed)
- Scaling production workloads with the confidence of managed PostgreSQL
If your team is using Hasura or PostGraphile, you've already embraced the power of exposing relational data over GraphQL. But as your architecture grows, the need for modularity, team ownership, and scale becomes clear and that's where GraphQL Federation shines.
With the Grafbase Postgres Extension, you can:
- Migrate from Hasura or PostGraphile without subgraph overhead: Integrate Postgres directly into your federated API, no need to manage subgraphs, custom stitching, or separate gateways.
- Use the CLI to generate your schema from your existing database: Introspect your Postgres instance and instantly publish the schema to the Grafbase registry.
- Adopt Federation without rearchitecting your backend: Grafbase lets you go from a monolithic GraphQL service to a federated graph, step by step — starting with your existing database.
If you've outgrown Hasura or PostGraphile and are looking for a future-proof path to GraphQL Federation, Grafbase makes the transition seamless.
Interested in learning more? Talk to our sales team.
Postgres is now just one line of config away.
With the Grafbase Postgres extension, you can finally bring a real relational database into your federated GraphQL architecture without setting up infrastructure, writing migration scripts, or juggling cloud services.
Whether you're building a startup MVP or scaling a production API, Postgres + Grafbase gives you the best of both worlds: the power of relational data with the power of GraphQL Federation.