GraphQL Code Generator
Code generation tool for GraphQL schemas and operations. Given a GraphQL schema and .graphql operation files, generates TypeScript types, React hooks (Apollo, urql, React Query), Kotlin data classes, Java code, and more. Eliminates manual type maintenance for GraphQL APIs — types always match the schema. Used widely with Apollo Client, urql, and any GraphQL-first TypeScript frontend.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
Build tool — minimal security surface. Schema introspection from authenticated endpoints needs secure headers handling in CI. The Guild maintains actively.
⚡ Reliability
Best When
You're building a TypeScript frontend or backend that calls a GraphQL API and want compile-time type safety that matches the actual schema.
Avoid When
You're using REST APIs or don't have TypeScript — graphql-codegen's value is type generation for TypeScript consumers of GraphQL schemas.
Use Cases
- • Generate TypeScript types and React hooks automatically from GraphQL schema for type-safe agent frontend data fetching
- • Generate Kotlin data classes from GraphQL schema for Android agents using Kotlin codegen plugin
- • Run codegen in CI/CD to catch schema drift — if the API schema changes and agent queries are now invalid, codegen fails the build
- • Generate typed GraphQL operation hooks for agent dashboards with zero manually maintained types
- • Use the 'client-preset' to generate co-located .gql.ts files with typed document nodes and result types for each operation
Not For
- • REST APIs — graphql-codegen is GraphQL-only; use openapi-typescript for REST API type generation
- • Runtime code — graphql-codegen is a build-time tool; generated types are consumed at development time and compiled away
- • Simple GraphQL queries without TypeScript — the overhead of codegen is not worth it for JavaScript without type checking
Interface
Authentication
Build tool — auth only needed to fetch remote schemas. Schema can be fetched via introspection from authenticated GraphQL endpoints with headers config.
Pricing
The Guild open source project. MIT license.
Agent Metadata
Known Gotchas
- ⚠ graphql-codegen requires operations to be in .graphql files or tagged template literals — inline strings are not processed; queries must be extracted to files or use gql tag
- ⚠ The client-preset generates co-located types; other presets require different plugin combinations — mixing presets without understanding plugin interactions creates duplicate or conflicting types
- ⚠ Schema fetching from authenticated endpoints requires adding headers in codegen.ts schema config — forgetting headers causes introspection to fail with authentication errors
- ⚠ Codegen generates code on every build if run in watch mode — avoid running codegen in production builds; use --config flag to separate dev and prod codegen configs
- ⚠ Fragment co-location requires fragmentMasking enabled in client-preset — without it, fragments are merged into operation types and fragment reuse loses type narrowing benefits
- ⚠ TypeScript strict mode may produce errors in generated code from older plugin versions — pin plugin versions and check generated code compatibility when upgrading graphql-codegen
Alternatives
Full Evaluation Report
Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for GraphQL Code Generator.
Scores are editorial opinions as of 2026-03-06.