Native Shell
Native Shell은 모든 플랫폼의 앱 안에서 만들어지는 AI UI입니다
graphpg는 PostgreSQL 스키마를 타입 안전 GraphQL·REST API로 변환
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.
개발 도구Rust · JavaScriptGitHub @mihailtd온라인운영자 미확인
써 보셨어요? 한 번만 눌러 주세요. 로그인은 필요 없어요.
개인 계정의 공개 저장소 소유자는 GitHub로 로그인해 운영자를 확인하고 소개를 직접 관리할 수 있습니다. 관리자 승인은 필요하지 않습니다.
로그인한 뒤 확인 파일을 만들어 이 저장소의 기본 브랜치에 30분 안에 커밋해 주세요. 다른 브랜치나 포크의 파일은 인정하지 않습니다. 파일을 올린 뒤 아래에서 확인하면 관리자 승인 없이 관리할 수 있습니다. 자격을 유지하려면 파일을 남겨 두세요.
로그인이 필요하면 로그인 화면으로 이동합니다. 로그인 후 이곳으로 돌아와 원하는 확인 버튼을 다시 눌러 주세요.
프로젝트 폴더에서 /nomorevibe verify를 실행하면 소유권을 확인하고 소개를 직접 관리할 수 있습니다.
1분 만에 확인하기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.
저장소 README에서 가져옴
README 전체를 불러오는 중입니다.
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 |