GraphQL Code Generator

A plugin-based CLI that generates typed code from a GraphQL schema and operations

Tool
npm
v7.4.0
11,264stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
92/100Excellent
Development Activity96
Maintenance96
Community76
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
76/100Good
Architecture80
Code Quality82
Innovation75
Learning Curve65

GraphQL Code Generator is a CLI tool, maintained by The Guild, that parses a GraphQL schema and your queries/mutations/subscriptions and emits generated code — TypeScript types, typed React hooks, resolver signatures, and more — through a large ecosystem of official and community plugins. Rather than hand-writing types that drift out of sync with the schema, teams run graphql-codegen (via a config file or the interactive init wizard) as part of their build or watch loop to keep frontend and backend code type-safe against the actual GraphQL contract.

What You Get

  • A graphql-codegen CLI with an interactive init wizard that scaffolds a working codegen config for your stack
  • A large official plugin catalog (TypeScript, TypeScript Operations, React Apollo, urql, Vue Apollo, resolvers, and more) plus support for custom plugins
  • Watch mode that regenerates output automatically as your schema or documents change
  • Presets (e.g. near-operation-file, client) for organizing generated output alongside source files

Common Use Cases

  • Generating TypeScript types for a GraphQL schema and operations so frontend code fails to compile on schema drift
  • Producing typed React/Vue/Angular hooks bound directly to specific GraphQL queries and mutations
  • Generating typed resolver signatures for a GraphQL server to keep backend implementations in sync with the schema
  • Running codegen as a watch-mode step in local development so generated types stay current with every schema edit

Under The Hood

Architecture - The CLI’s src/bin.ts entry point delegates to cli.ts, which parses flags and hands off to codegen.ts (598 lines) — the orchestration core that loads config via config.ts (568 lines, using cosmiconfig and graphql-config.ts), loads the schema/documents through @graphql-tools loaders (file, git, GitHub, URL), resolves the requested plugins via plugins.ts/presets.ts, and hands the assembled context to @graphql-codegen/core for the actual generation pass, with generate-and-save.ts and hooks.ts handling output writing and lifecycle hooks (beforeAllFileWrite, etc.); documentTransforms.ts applies pre-generation transforms like @babel/generator-based document rewriting. Tech Stack - A pnpm-workspace TypeScript monorepo built with modern tooling (Vitest, ESLint flat config, Prettier), where the CLI package itself depends on @graphql-codegen/core, @graphql-codegen/client-preset, @graphql-codegen/plugin-helpers, the @graphql-tools loader family, @inquirer/prompts for the init wizard, cosmiconfig for config discovery, and chalk for terminal output. Code Quality - The CLI package has a dedicated tests/ directory with Vitest specs covering config loading, CLI flags, the init wizard, watch-mode behavior, and end-to-end generate-and-save flows, reflecting the broader monorepo’s very active development and maintenance-consistency scores from GitHub activity data. API Design - The graphql-codegen init wizard walks new users through schema location, target plugins, and output paths in one interactive flow, while advanced users configure everything declaratively via a codegen.yml/codegen.ts config file discovered through cosmiconfig, giving both a low-friction onboarding path and a fully scriptable, CI-friendly configuration surface.

Used by 48 apps in this directory

TypeScript
87%
Other

AFFiNE

Productivity · Project Management · Note Taking

72,238

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
67
Dependency
Built with
TypeScript87%
Updated yesterday
TypeScript
87%
Other

AFFiNE

Productivity · Project Management · Note Taking

72,238

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
67
Dependency
Built with
TypeScript87%
Updated yesterday
TypeScript
87%
Other

AFFiNE

Productivity · Project Management · Note Taking

72,238

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
67
Dependency
Built with
TypeScript87%
Updated yesterday
TypeScript
96%
Other

Amplication

Developer Tools · AI Code Assistants · Automation

16,011

Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.

View details
60
Repo Health
84
Technical
60
Dependency
Built with
TypeScript96%
Updated 2 months ago
TypeScript
96%
Other

Amplication

Developer Tools · AI Code Assistants · Automation

16,011

Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.

View details
60
Repo Health
84
Technical
60
Dependency
Built with
TypeScript96%
Updated 2 months ago
TypeScript
96%
Other

Amplication

Developer Tools · AI Code Assistants · Automation

16,011

Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.

View details
60
Repo Health
84
Technical
60
Dependency
Built with
TypeScript96%
Updated 2 months ago
Go
54%
Apache 2.0

Authgear

Authentication

2,028

Open-source, self-hostable authentication platform with passkeys, biometric login, SSO, MFA, and GraphQL admin API — a full Auth0/Clerk/Firebase alternative for SaaS and mobile apps.

View details
88
Repo Health
81
Technical
68
Dependency
Built with
Go54%
HTML25%
TypeScript18%
Updated 3 days ago
Go
54%
Apache 2.0

Authgear

Authentication

2,028

Open-source, self-hostable authentication platform with passkeys, biometric login, SSO, MFA, and GraphQL admin API — a full Auth0/Clerk/Firebase alternative for SaaS and mobile apps.

View details
88
Repo Health
81
Technical
68
Dependency
Built with
Go54%
HTML25%
TypeScript18%
Updated 3 days ago
Go
54%
Apache 2.0

Authgear

Authentication

2,028

Open-source, self-hostable authentication platform with passkeys, biometric login, SSO, MFA, and GraphQL admin API — a full Auth0/Clerk/Firebase alternative for SaaS and mobile apps.

View details
88
Repo Health
81
Technical
68
Dependency
Built with
Go54%
HTML25%
TypeScript18%
Updated 3 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search