Native Shell
Native Shell: AI-generated UI, native in your app, on every platform. Apps on iOS, Android, macOS, Windows and Linux, GPUI apps and web pages load signed, sandboxed TSX modules at run time and draw th
graphpg turns a PostgreSQL schema into type-safe GraphQL and REST APIs, with the SDL and OpenAPI 3.1 files your TypeScript types come from. Built for developers and their coding agents.
Developer toolsRust · JavaScriptGitHub @mihailtdOnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
Owners of public repositories under a personal GitHub account can sign in to verify ownership and manage the introduction themselves. No administrator approval is needed.
Sign in, generate a verification file, and commit it to this repository’s default branch within 30 minutes. Files on other branches or forks do not count. Then check the file below to manage the project without administrator approval. Keep the file to retain your access.
If needed, you will go to sign-in. After signing in, return here and press your chosen verification button again.
Run /nomorevibe verify in your project folder to verify ownership and manage the introduction yourself.
Verify in one minuteAsk about other verification options
Instant GraphQL & REST APIs from PostgreSQL in a single Rust binary. Compiles queries to single SQL statements with zero N+1, native pgvector/hybrid search, Relay pagination, RLS, and OpenAPI 3.1. Ready for AI agents.
Taken from the repository README
Loading the full README.
Read the full README ↗A GraphQL and REST server for PostgreSQL. Point it at a database and it serves a GraphQL API and a REST API (described by an OpenAPI 3.1 document) generated from the schema: tables, relations, constraints, types, functions and privileges. There is no resolver code to write and no schema to maintain in two places.
For AI work it covers two jobs. Agents that use your data get typed tools over it: vector, BM25 and hybrid search from your indexes, and MCP through Apollo's MCP Server, limited to the operations you list and to what Row-Level Security lets the agent's token see. Agents that build applications get a typed contract to code against: the GraphQL SDL and the OpenAPI document are generated from the database, pinned in CI, and errors carry typed codes. See AI agents and end-to-end type safety.
graphpg is a single Rust binary. It reads PostgreSQL's catalogs at startup, builds the APIs, and compiles each request into one SQL statement (lateral joins and JSON aggregation, so nested selections don't cause N+1 queries). Both APIs are planned onto the same engine, so they share filters, pagination, nested writes, typed errors, authorization and safety limits.
Status: 1.1, the API is stable. Versions follow semantic versioning: the GraphQL and REST APIs derived from a database, error codes, configuration and CLI change incompatibly only in a major version. The behaviour documented here is covered by an integration test suite that runs against PostgreSQL 18. See the changelog.
git clone https://github.com/mihailtd/graphpg && cd graphpg/examples/blog
docker compose up --build
Open http://localhost:4000/graphiql for GraphQL, or http://localhost:4000/scalar for the REST API reference. The blog example loads a small schema and shows relations, filtering, pagination, search and nested writes in both.
Run the published container image against your own database:
docker run --rm -p 4000:4000 \
-e DATABASE_URL=postgres://user:[email protected]/mydb \
ghcr.io/mihailtd/graphpg:1.3.0 --mode dev
The image is a static binary on distroless/static (about 27 MB with the embedded GraphiQL and Scalar UIs, no shell, non-root, signed with Sigstore). See running in a container.
Or build from source:
cargo install --path crates/graphpg # or: cargo build --release
DATABASE_URL=postgres://user:pass@localhost/mydb graphpg --mode dev
{
authors {
username
postsConnection(first: 5, orderBy: [CREATED_AT_DESC]) { nodes { title tags { name } } }
}
}
The same data over REST:
curl -g 'localhost:4000/rest/posts?filter[status][eq]=PUBLISHED&order=-createdAt&first=5&include=tags'
curl -X POST localhost:4000/rest/authors -H 'content-type: application/json' \
-d '{"username": "ada", "displayName": "Ada", "posts": {"create": [{"title": "Hello", "body": "Hi there"}]}}' # a nested write
node(id:) and global IDs.some / every / none), grouped aggregates, and ordering by related columns.EMAIL_TAKEN, AUTHOR_NOT_FOUND)./rest: lists with typed filters, ordering, keyset pagination and embedding; single-row reads and writes with ETag / If-Match; nested writes and bulk creates; aggregates and grouped aggregates; functions at /rest/rpc/…; search endpoints; RFC 9457 problem+json errors with the same typed codes. It is described by an OpenAPI 3.1 document (typed parameters, nested-write bodies) and a bundled Scalar reference. See the REST API guide and the comparison with PostgREST.STABLE functions become queries, VOLATILE ones mutations, and functions of a row become computed fields.ltree, jsonb, pgvector, PostGIS.WITHOUT OVERLAPS, PERIOD), RETURNING OLD, JSON_TABLE views, MERGE-based syncing of children.rbac.enabled, the GraphQL schema, REST API and OpenAPI document are pruned to what the connecting role may do, from GRANTs.Schema design stays in SQL. An optional graphpg.yaml renames and hides things and declares the keys of views it cannot detect; it is not required.
The guides are also published as a website at https://mihailtd.github.io/graphpg/.
| AI agents | MCP tools for agents through Apollo's MCP Server, vector and hybrid search for retrieval, typed contracts for agents that write code, and the guardrails |
| End-to-end type safety | From a migration to TypeScript errors in the app: exporting the SDL and OpenAPI document, GraphQL Code Generator and openapi-typescript, what a column rename looks like, where the chain stops |
| Configuration | Running graphpg, environment variables, graphpg.yaml, safety limits, pinned schemas, multiple schemas, dev mode |
| Schema mapping | How tables, types, functions and constraints become GraphQL and REST |
| GraphQL API | Pagination, filtering, aggregates, mutations, nested writes, errors, search, limits |
| REST API | Filtering, pagination, embedding, writes and nested writes, aggregates, functions, search, errors, limits |
| Authentication | OAuth 2.0 resource server and Row-Level Security |
| Federation and RBAC | Apollo Federation subgraphs and schema pruning by role |
DATABASE_URL. Turn it on and give the engine a low-privilege login role before exposing it (guide).debug.sql / debug.explain settings (which return generated SQL) are for development: they are on or allowed only in --mode dev.statement_timeout); review the safety limits for your deployment.docker compose up -d # PostgreSQL 18 with pgvector, database graphpg_test
cargo test --workspace # TEST_DATABASE_URL overrides the connection string
Each test file creates the schema it needs. See CONTRIBUTING.md.
Dual-licensed under MIT or Apache-2.0, at your option. Third-party test material is credited in NOTICE.
graphpg is built by Mihai Farcas (@mihailtd). For consulting on PostgreSQL APIs and AI agents in production, see innovi.pro.
statement_timeoutgraphpg schema export writes the GraphQL SDL and the OpenAPI document; --check fails CI when they are out of date, and production refuses to start on drift.subscription, its result sent again when it changes, under Row-Level Security; over WebSocket (graphql-transport-ws), SSE and multipart HTTP; batched re-runs on read replicas, nothing installed in the database (subscriptions).@defer / @stream, streaming NDJSON/CSV export and COPY import, read replicas, OpenTelemetry spans.| Performance | Indexes and settings, replicas |
| Observability | Prometheus metrics, OpenTelemetry traces, metrics and logs (OTLP), JSON logs; Grafana LGTM |
| Event triggers | Webhooks on row changes (captured in the change's transaction) and on schedules: delivery, retries, signatures |
| Subscriptions | Live queries: transports, authentication and RLS, what they cost, scaling on replicas, Apollo Router |
| Other databases and files | Foreign data wrappers (postgres_fdw, file_fdw, Parquet, S3): keys, relations, authorization, performance and caveats |
| Extending graphpg | Where computed fields, custom operations, side effects, jobs and external logic go, and why there are no plugins |
| Comparison | How graphpg differs from PostGraphile and Hasura (GraphQL) and from PostgREST (REST) |
| Versioning | What semantic versioning covers (the derived APIs, error codes, configuration, CLI), deprecation, supported PostgreSQL |
| GraphQL and OpenAPI parity | What each API knows about the database that the other does not, and whether it could be ported |