<div class="hero-section">
<h1 class="hero-title">gRPC-GraphQL Gateway</h1>
<p class="hero-subtitle">
A high-performance Rust gateway that bridges gRPC services to GraphQL with full Apollo Federation v2 support.
</p>
<div class="hero-badges">
<a href="https://crates.io/crates/grpc-graphql-gateway"><img src="https://img.shields.io/crates/v/grpc-graphql-gateway.svg?style=flat-square&color=fe7d37" alt="Crates.io"></a>
<a href="https://github.com/Protocol-Lattice/grpc_graphql_gateway/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square" alt="License: MIT"></a>
</div>
</div>
Transform your gRPC microservices into a unified GraphQL API with zero GraphQL code. This gateway dynamically generates GraphQL schemas from protobuf descriptors and routes requests to your gRPC backends via Tonic, providing a seamless bridge between gRPC and GraphQL ecosystems.
## โจ Features
### Core Capabilities
- ๐ **Dynamic Schema Generation** - Automatic GraphQL schema from protobuf descriptors
- โก **Full Operation Support** - Queries, Mutations, and Subscriptions
- ๐ **WebSocket Subscriptions** - Real-time data via GraphQL subscriptions (`graphql-ws` protocol)
- ๐ค **File Uploads** - Multipart form data support for file uploads
- ๐ฏ **Type Safety** - Leverages Rust's type system for robust schema generation
### Federation & Enterprise
- ๐ **Apollo Federation v2** - Complete federation support with entity resolution
- ๐ **Entity Resolution** - Production-ready resolver with DataLoader batching
- ๐ซ **No N+1 Queries** - Built-in DataLoader prevents performance issues
- ๐ **All Federation Directives** - `@key`, `@external`, `@requires`, `@provides`, `@shareable`
- ๐ **Batch Operations** - Efficient entity resolution with automatic batching
### Developer Experience
- ๐ ๏ธ **Code Generation** - `protoc-gen-graphql-template` generates starter gateway code
- ๐ง **Middleware Support** - Extensible middleware for auth, logging, and observability
- ๐ **Rich Examples** - Complete working examples for all features
- ๐งช **Well Tested** - Comprehensive test coverage
### Production Ready
- ๐ฅ **Health Checks** - `/health` and `/ready` endpoints for Kubernetes
- ๐ **Prometheus Metrics** - `/metrics` endpoint with request counts and latencies
- ๐ญ **OpenTelemetry Tracing** - Distributed tracing with GraphQL and gRPC spans
- ๐ก๏ธ **DoS Protection** - Query depth and complexity limiting
- ๐ **Introspection Control** - Disable schema introspection in production
- ๐ **Query Whitelisting** - Restrict to pre-approved queries (PCI-DSS compliant)
- โก **Rate Limiting** - Built-in rate limiting middleware
- ๐ฆ **Automatic Persisted Queries** - Reduce bandwidth with query hash caching
- ๐ **Circuit Breaker** - Prevent cascading failures
- ๐๏ธ **Response Caching** - In-memory LRU cache with TTL
- ๐ **Batch Queries** - Execute multiple operations in one request
- ๐ **Graceful Shutdown** - Clean shutdown with request draining
- ๐๏ธ **Response Compression** - Automatic gzip/brotli compression
- ๐ **Header Propagation** - Forward HTTP headers to gRPC backends
- ๐งฉ **Multi-Descriptor Support** - Combine multiple protobuf descriptors
## Why gRPC-GraphQL Gateway?
If you have existing gRPC microservices and want to expose them via GraphQL without writing GraphQL resolvers manually, this gateway is for you. It:
1. **Reads your protobuf definitions** - Including custom GraphQL annotations
2. **Generates a GraphQL schema automatically** - Types, queries, mutations, subscriptions
3. **Routes requests to your gRPC backends** - With full async/await support
4. **Supports federation** - Build a unified supergraph from multiple services
## Quick Example
```rust
use grpc_graphql_gateway::{Gateway, GrpcClient};
const DESCRIPTORS: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/descriptor.bin"));
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let gateway = Gateway::builder()
.with_descriptor_set_bytes(DESCRIPTORS)
.add_grpc_client(
"greeter.Greeter",
GrpcClient::builder("http://127.0.0.1:50051").connect_lazy()?,
)
.build()?;
gateway.serve("0.0.0.0:8888").await?;
Ok(())
}
```
**That's it!** Your gateway is now running at:
- GraphQL HTTP: `http://localhost:8888/graphql`
- GraphQL WebSocket: `ws://localhost:8888/graphql/ws`
## Getting Started
Ready to dive in? Start with the [Installation](./getting-started/installation.md) guide.