$ show ghostdogpr/caliban
Caliban is a purely functional Scala GraphQL library built on ZIO, providing fully type-safe, boilerplate-free schema derivation from case classes, an efficient execution engine with batched/deferred resolution, and support for WebSocket subscriptions, SSE, and incremental delivery (@defer/@stream). It implements Apollo Federation (v1 and v2) with entity resolvers, tracing, and schema reporting. The library offers a type-safe client module for Scala.js and JVM, an sbt plugin for compile-time code generation from GraphQL schemas, and adapters for http4s, Akka HTTP, Pekko HTTP, Play, and ZIO HTTP. Interoperability is provided through Cats Effect, Monix, Tapir, and multiple JSON libraries (circe, zio-json, jsoniter, play-json). The repository includes extensive tests, JMH benchmarks, and Apollo compatibility tests. It is actively maintained and cross-compiled for Scala 2.13 and 3.
The LLM identified 3 files worth highlighting for reuse:
Implements the full GraphQL spec parsing using FastParse combinators. Produces a typed AST (Document, Selection, Value, etc.) and handles syntax, fragments, variables, and directives. The parser is self-contained within fastparse and can be extracted and reused in any Scala project that needs to parse GraphQL documents, independent of the rest of Caliban.
Provides a self-contained Cursor abstraction for Relay-compatible pagination. Defines a sealed trait with encode/decode logic using Base64 encoding, independent of Caliban's internal types. This can be extracted and reused in any GraphQL server implementing the Relay cursor connections spec.
Defines the Connection, Edge, and PageInfo case classes and helper functions for Relay-style paginated queries. Has zero internal dependencies other than standard Scala libraries, making it highly portable. The pattern is a reusable building block for any GraphQL implementation that needs standard pagination types.