Registry / devops / graphql-codegen

graphql-codegen

JSON →
library0.4.0jsnpmunverified

CLI tool to generate typed client code (Swift initially, later TypeScript/Flow) from GraphQL schemas and query documents. Version 0.4.0 is early stage — only Swift output, no fragment support beyond exact type matches. Unstable API. Superseded by @graphql-codegen/cli (v1+) and Apollo CLI. Releases were sporadic. Differentiated as first codegen from Apollo, but quickly replaced.

npm install graphql-codegen
INSTALL
IMPORT
SIG · GRAPHQL-CODEGEN
G
graphql-codegen
devopsjavascriptv0.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CLI
apollo-codegen generate ...
import { generate } from 'apollo-codegen'
This is a CLI tool, not a library import.
downloadSchema
apollo-codegen download-schema
const { downloadSchema } = require('apollo-codegen')
CLI commands, not programmatic API.

Install CLI, download schema with auth header, generate Swift code from .graphql files.

npm install -g apollo-codegen@0.4.0 apollo-codegen download-schema http://localhost:4000/graphql --output schema.json --header "Authorization: Bearer ${AUTH_TOKEN}" apollo-codegen generate 'queries/**/*.graphql' --schema schema.json --output API.swift --namespace MyAPI
Debug
Known issues
deprecatedThis package is deprecated in favor of @graphql-codegen/cli or Apollo CLI.
fix
Migrate to @graphql-codegen/cli or @apollo/cli.
affects: >=0
gotchaOnly generates Swift code (no TypeScript/Flow support).
fix
Use @graphql-codegen/cli for multi-language output.
affects: <=0.4.0
breakingFragments are only supported if their type condition matches exactly the parent type.
fix
Rewrite fragments to match parent type or use later version.
affects: <=0.4.0
gotchaProgrammatic API is not stable — only CLI commands are documented.
fix
Use CLI directly or migrate to newer tools.
affects: <=0.4.0
Errors
Common errors & fixes
Error: Cannot find module 'apollo-codegen'
Global install not found or not in PATH.
fix
Install globally: npm install -g apollo-codegen@0.4.0
Error: Invalid schema file
Schema file path is incorrect or introspection failed.
fix
Ensure download-schema succeeded and path is correct.
Error: Unsupported fragment type condition
Fragment type condition does not match parent type.
fix
Change fragment type condition to match exact parent type.
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies
graphqlrequiredrequired for schema introspection and parsing
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
graphql-codegen — npm install graphql-codegen · libregistry