grpc_graphql_gateway 1.2.4

A Rust implementation of gRPC-GraphQL gateway - generates GraphQL execution code from gRPC services
<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.