← Back to archive

Repo of the Day

Oualitsen/graphlink: Type-safe code generator for GraphQL schemas — produces clients and server interfaces for Dart, Flutter, Java, and Spring Boot. Features built-in caching with TTL/tag-based invalidation, JSON serialization, and auto-generated fragmen…

Published: Oct 10, 2026

Open repository ↗

Type-safe code generator for GraphQL schemas — produces clients and server interfaces for Dart, Flutter, Java, and Spring Boot. Features built-in caching with TTL/tag-based invalidation, ...

Summary

GraphLink is a CLI tool (glink) that reads a single .graphql schema file and generates type-safe client and server code for Dart, Flutter, Java, Spring Boot, TypeScript, Kotlin, and Express/Apollo. The generated files have no runtime dependency on GraphLink itself, so generated artifacts compile and run independently of the generator. It also bakes cache TTLs, tag-based invalidation, and error capture into the schema via custom directives.

What it is useful for

Teams that maintain one GraphQL backend and ship clients across multiple stacks — for example a Flutter mobile app and a Java/Spring Boot backend, or a TypeScript web client and a Java service. GraphLink is documented to produce:

  • Fully resolved return types for Java (no generics like TypeReference<GraphQLResponse<Map<String, Object>>> at the call site), which it claims other Java GraphQL clients require.
  • Schema-driven caching via @glCache(ttl: "...", tags: [...]) and @glCacheInvalidate(tags: [...]) directives. Cache entries are keyed by operation name plus variables, and tag invalidation propagates from mutations. Persistent storage is not built in — you implement GraphLinkCacheStore yourself.
  • Minimal query strings per request, avoiding the full-schema dumps that can break Spring Boot's strict GraphQL validation.
  • Inline error handling via @glCaptureErrors (or captureErrors: true globally), returning a FullResponse with data and errors side by side.
  • Server scaffolding: in mode: "server", it generates Spring @Controller classes wired into Spring GraphQL, plus an VehicleService interface you implement, and similarly for Express/Apollo with a generated createServer() entry point.

How engineers can use it

Install the CLI by downloading the native binary for your platform from the releases page (macOS ARM/x64, Linux x64/ARM64, Windows x64 are listed) and placing it on your PATH, or add it as a dev dependency with flutter pub add --dev graphlink / dart pub add --dev graphlink.

Typical workflow:

  1. Author a .graphql schema. Add directives such as @glCache(ttl: "2m", tags: ["vehicles"]) on queries and @glCacheInvalidate(tags: ["vehicles"]) on mutations that should bust them.
  2. Add a glink.json (or .yaml/.yml) in the project root with schemaPaths, mode ("client" or "server"), typeMappings, and outputDir.
  3. Run glink to generate, glink -c config.json for an explicit config, or glink -w to watch and regenerate on save. Regeneration is documented as taking milliseconds even on large schemas.

Then call generated methods like client.queries.getVehicle("42") in Java, Dart, or TypeScript — all return fully typed objects. For server targets, implement the generated service interface; routing and controller wiring are produced for you. Full per-target guides and a directives reference live at graphlink.dev/docs (see the README for links).