Skip to main content

Launch a GraphQL API Over Your Own PostgreSQL, in Minutes

· 4 min read
FoundryDB Team
Engineering @ FoundryDB

Building a GraphQL API used to be a project. You stand up a server, wire it to a database, hand-write resolvers for every type, add a subscription transport, build an authorization layer, and keep all of it in sync with your schema as it changes. Weeks of plumbing before a single useful query runs.

The Launch a GraphQL API stack collapses that into one button. Pick it, accept the cost preview, and a few minutes later you have a production GraphQL API over your own PostgreSQL: queries, mutations, real-time subscriptions, and fine-grained permissions. No backend code. EU-resident from the first request.

graphql-api stack · compose & introspect
RUNNING Stack wired · GraphQL endpoint live
Stack Templategraphql-apilaunch ⇉PostgreSQLtables · :5432Hasurawired · introspectsintrospect →GraphQL APIqueries · mutations · subscriptions
TemplatePostgreSQLHasuraGraphQL API (introspected)wiring (env injected)

Two resources, already wired

The stack is pure composition over two FoundryDB primitives:

  • Your own PostgreSQL, a managed database that you own, can connect to directly, and can scale and back up like any other service.
  • A Hasura app, attached to that database, serving the GraphQL API and an interactive console over a real foundrydb.com hostname with a real certificate.

You do not connect them by hand. When the stack reaches its wiring step, the engine attaches Hasura to the database and injects HASURA_GRAPHQL_DATABASE_URL, the connection string Hasura uses to reach Postgres. Hasura connects, introspects your schema, and exposes it. There is no connection string to copy and no settings panel to fill in.

Your schema becomes your API

This is the part that feels like magic the first time. Hasura does not own your data. PostgreSQL does. Hasura reads the database schema and projects a GraphQL API onto it, live.

Create a table and track it, and it is queryable. Add a foreign key, and Hasura models it as a nested relationship in the graph, so a posts table that references authors gives you this for free:

query {
posts {
title
author {
name
}
}
}

You wrote no resolver. Insert a row with a mutation, subscribe to a live query over a WebSocket and watch it update on its own, and scope access per role with row and column filters that Hasura pushes down into the database. The whole authorization layer is configuration, not application code.

Launch it

The flow is the same as every FoundryDB stack: preview the cost, accept it, launch, poll.

# Preview
curl -X POST https://api.foundrydb.com/stacks/preview \
-H "Authorization: Bearer $FOUNDRYDB_TOKEN" \
-H "Content-Type: application/json" \
-d '{"template_name": "graphql-api"}'

# Launch with the monthly_total you just saw
curl -X POST https://api.foundrydb.com/stacks \
-H "Authorization: Bearer $FOUNDRYDB_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "my-graphql-api",
"template_name": "graphql-api",
"accepted_monthly_cost": 24.00
}'

Poll GET /stacks/{id} until it reaches Running, then open the endpoint_url. The GraphQL endpoint lives at /v1/graphql on that host, and the Hasura console is at the root.

The guarantees come with it

This stack inherits everything that makes FoundryDB stacks worth trusting:

  • A hard cost preview before launch. You see exactly what the database and the app will cost, and you accept that number before anything is provisioned.
  • Atomic rollback. If either resource fails to come up, the whole launch rolls back. You never end up with an orphaned database quietly costing you money.
  • EU residency. Both the database and the Hasura app run within the platform's European footprint. Your data and your GraphQL traffic stay in Europe.
  • It is yours. The PostgreSQL service is an ordinary managed database in your account. Connect to it directly, add extensions, scale it, back it up.

Try it

Stop building a GraphQL backend by hand. Launch the finished thing, point it at your own Postgres, and start querying.

The Launch a GraphQL API tutorial walks through the whole flow, from launch to your first query, mutation, subscription, and permission. Open the catalog and ship a GraphQL API today.