qmetrics.net

gqlgen

Schema-first Go library for GraphQL server codegen

gqlgen screenshot

gqlgen is a Go library for building GraphQL servers with strong typing and generated models. You define the API in GraphQL SDL and use go generate to produce server scaffolding.

Overview

gqlgen targets developers who want to run GraphQL APIs in Go without hand-writing repetitive resolver boilerplate. The workflow is schema-first: you describe types and operations in the GraphQL Schema Definition Language, then codegen fills in models and wiring so resolvers stay type-safe and avoid generic map-based payloads.

The library emphasizes compile-time safety and generated code for routine pieces of a server. Configuration in gqlgen.yml lets you map GraphQL types to your own Go structs, force resolvers for specific fields, control concurrency for field resolution, and remap scalars such as ID to integers or strings. Directives support inline model and field hints when you want schema and Go types to stay aligned.

Getting started involves adding gqlgen as a tool dependency, initializing config, generating models, and running a small GraphQL server process. Documentation points to tutorials, real-world examples, and reference material for the APIs. The project also documents patterns for nested data, such as loading related records only when the client requests those fields.

Compared with other Go GraphQL implementations, the project invites side-by-side evaluation on its site. It focuses on codegen and schema-first development rather than being a hosted product you deploy on its own.

Key features

  • Schema-first GraphQL SDL workflow
  • go generate based code generation
  • Strong typing without map[string]interface{}
  • Custom models and explicit field resolvers
  • Configurable ID scalar mapping
  • Concurrent field resolvers with worker limits
  • Directives for inline Go model binding
  • Optional interface getter generation

Use cases

  • New Go GraphQL APIs from an SDL schema
  • Type-safe resolvers for production services
  • Controlled loading of nested graph fields
  • Remapping GraphQL ID types to Go types
  • Comparing Go GraphQL server approaches

Tags

Similar software

FastAPI

Python web framework for building APIs with type hints

FastAPI is a Python web framework for building APIs using standard type hints. It builds on Starlette and Pydantic and generates interactive OpenAPI documentation for the endpoints you define.

★ 105.1k⟳ 9 days agoMIT

NestJS

Progressive TypeScript framework for Node.js backends

Nest organizes Node server apps with modules, dependency injection, and first-party packages for auth, data, queues, and observability.

★ 77.2k⟳ todayMIT

OkHttp

HTTP client for JVM, Android, and GraalVM

OkHttp is an HTTP client library tuned for efficient networking on Android, Java, and GraalVM native images. It offers synchronous and asynchronous call APIs with a fluent request builder.

★ 47.1k⟳ yesterdayApache-2.0
Frameworks & PlatformsDesktop/CLI app

gRPC

Cross-language remote procedure call framework

gRPC is an RPC framework that lets client and server programs communicate transparently and supports building connected, multi-language systems.

★ 45.5k⟳ todayApache-2.0

tRPC

End-to-end typesafe TypeScript APIs without code generation

tRPC helps teams define server procedures and call them from clients with full TypeScript types for inputs, outputs, and errors—no schemas or codegen step.

★ 40.9k⟳ todayMIT
Frameworks & PlatformsDesktop/CLI app

go-zero

Cloud-native Go microservices and RPC framework

go-zero is a Go web and RPC framework with code generation, built-in resilience middleware, and tooling aimed at stable high-traffic services.

★ 33.5k⟳ 9 days agoMIT