Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

API Documentation

The full Rust API documentation is available on docs.rs:

📚 docs.rs/grpc_graphql_gateway

Main Types

Gateway

The main entry point for creating and running the gateway.

use grpc_graphql_gateway::Gateway;

let gateway = Gateway::builder()
    // ... configuration
    .build()?;

GatewayBuilder

Configuration builder with fluent API.

GrpcClient

Manages connections to gRPC backend services.

use grpc_graphql_gateway::GrpcClient;

// Lazy connection (connects on first request)
let client = GrpcClient::builder("http://localhost:50051")
    .connect_lazy()?;

// Immediate connection
let client = GrpcClient::new("http://localhost:50051").await?;

SchemaBuilder

Low-level builder for the dynamic GraphQL schema.

Module Reference

ModuleDescription
gatewayMain Gateway and GatewayBuilder
schemaSchema generation from protobuf
grpc_clientgRPC client management
federationApollo Federation support
middlewareRequest middleware
cacheResponse caching
compressionResponse compression
circuit_breakerCircuit breaker pattern
persisted_queriesAPQ support
healthHealth check endpoints
metricsPrometheus metrics
tracing_otelOpenTelemetry tracing
shutdownGraceful shutdown
headersHeader propagation

Re-exported Types

pub use gateway::{Gateway, GatewayBuilder};
pub use grpc_client::GrpcClient;
pub use schema::SchemaBuilder;
pub use cache::{CacheConfig, ResponseCache};
pub use compression::{CompressionConfig, CompressionLevel};
pub use circuit_breaker::{CircuitBreakerConfig, CircuitBreaker};
pub use persisted_queries::PersistedQueryConfig;
pub use shutdown::ShutdownConfig;
pub use headers::HeaderPropagationConfig;
pub use tracing_otel::TracingConfig;
pub use middleware::{Middleware, Context};
pub use federation::{EntityResolver, EntityResolverMapping, GrpcEntityResolver};

Error Types

use grpc_graphql_gateway::{Error, Result};

// Main error type
enum Error {
    Schema(String),
    Io(std::io::Error),
    Grpc(tonic::Status),
    // ...
}

Async Traits

When implementing custom resolvers or middleware, you’ll use:

use async_trait::async_trait;

#[async_trait]
impl Middleware for MyMiddleware {
    async fn call(&self, ctx: &mut Context, next: ...) -> Result<()> {
        // ...
    }
}