REST Transport
Annotation-driven REST endpoints, OpenAPI spec, HTTP status codes.
fraiseql run serves GraphQL and REST simultaneously on a single port. gRPC is also available when FraiseQL is built with the grpc-transport Cargo feature. HTTP/2 content-type negotiation distinguishes gRPC (application/grpc) from HTTP/1.1 REST and GraphQL traffic. No proxy layer, no separate services.
SDK decorators (Python, TypeScript, Go, +7 more) ↓ fraiseql compile ↓ schema.compiled.json ↓ fraiseql run (single Rust binary, port 8080) ╱ | ╲GraphQL REST gRPCPOST /graphql GET /rest/.. UserService/GetUser JSON JSON Protobuf ╲ | ╱ Transport-aware DB views ↓PostgreSQL · MySQL · SQL Server · SQLiteThe compiled schema is the single source of truth. Each transport reads from it; none requires separate schema definitions or mapping layers.
| Use case | Transport | Why |
|---|---|---|
| Public API, third-party integrations | REST | Universal, cacheable, OpenAPI spec |
| Frontend with complex data needs | GraphQL | Field selection, nested queries, subscriptions |
| Service-to-service in gRPC mesh | gRPC | Binary wire, no JSON overhead, strong typing |
| Real-time updates | WebSocket | Push-based, persistent connection |
| Mobile clients | REST or GraphQL | HTTP/1.1 compatible |
Nothing stops you from enabling all three simultaneously. Clients use whichever transport fits their context.
| Feature | GraphQL | REST | gRPC |
|---|---|---|---|
| Authentication | ✅ | ✅ | ✅ |
| Rate limiting | ✅ | ✅ | ✅ |
| RBAC | ✅ | ✅ | ✅ |
| APQ / Persisted queries | ✅ | ❌ (path-based) | ❌ (method-based) |
| OpenAPI spec | ❌ | ✅ | ❌ |
| .proto generation | ❌ | ❌ | ✅ |
| Introspection | ✅ | ❌ | ✅ (reflection) |
| Subscriptions | ✅ | ❌ | ✅ (server streaming) |
| Response caching | ✅ | ✅ | ❌ |
| HTTP/1.1 compatible | ✅ | ✅ | ❌ (requires HTTP/2) |
The compiler generates different database view shapes depending on transport:
GraphQL and REST use JSON-shaped views. PostgreSQL produces JSON directly via json_agg and row_to_json. The server passes the JSON text through without re-serializing.
gRPC uses row-shaped views. PostgreSQL returns typed columns. The server maps those columns to protobuf fields. No JSON is produced or parsed anywhere in the path.
This distinction is why the gRPC path has lower per-request overhead — the database does less work and the wire payload is smaller. Both view shapes are generated from the same SDK annotations at compile time.
Enabling REST or gRPC does not introduce new infrastructure. All three transports run through the same stack:
Configure once in fraiseql.toml or via environment variables — it applies to every transport.
REST Transport
Annotation-driven REST endpoints, OpenAPI spec, HTTP status codes.
gRPC Transport
Binary wire format, auto-generated .proto, server streaming.
Subscriptions
Real-time WebSocket subscriptions and gRPC server streaming.
GraphQL API Reference
Full GraphQL API reference, introspection, and persisted queries.