Native Shell
Native Shell:AI 生成的 UI,在你的应用中原生呈现,覆盖每个平台。iOS、Android、macOS、Windows 与 Linux 上的应用、GPUI 应用与网页在运行时加载已签名、沙箱隔离的 TSX 模块并绘制 th
AI 翻译
个人 GitHub 账号下公开仓库的所有者可以登录并验证所有权,自行管理介绍,无需管理员批准。
登录并生成验证文件,在 30 分钟内将其提交到此仓库的默认分支。其他分支或分叉仓库中的文件无效。然后在下方检查文件,即可无需管理员批准直接管理项目。请保留文件以维持管理权限。
如需登录,将前往登录页面。登录后请回到此处,再次点击所选的验证按钮。
在项目文件夹中运行 /nomorevibe verify,即可验证所有权并自行管理介绍。
一分钟完成验证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 |