GraphQL Code Generator

GraphQL Code Generator

  • API & Documentation
  • GitHub
  • Help

›Plugins

Getting Started

  • What is GraphQL Code Generator?
  • Codegen Options Config
  • `schema` field
  • `documents` field
  • `config` field
  • `require` field
  • Lifecycle Hooks
  • Development Workflow
  • Programmatic Usage
  • Further Reading

Plugins

  • Available Plugins
  • TypeScript
  • TypeScript Operations
  • TypeScript 1.0 Compatibility
  • TypeScript Resolvers
  • TypeScript GraphQL Files Modules
  • TypeScript document nodes
  • TypeScript MongoDB
  • TypeScript React Apollo
  • TypeScript Apollo Angular
  • TypeScript Stencil Apollo
  • TypeScript Urql
  • TypeScript GraphQL-Request
  • Flow Types
  • Flow Resolvers
  • Flow Operations
  • Kotlin
  • Java
  • Java Resolvers
  • Java Apollo Android
  • Fragment Matcher
  • Introspection
  • Add
  • Time
  • Schema AST
  • Reason Client
  • Relay Operation Optimizer.

Presets

  • near-operation-file
  • import-types

Integrations

  • Apollo Local State
  • Create-React-App
  • GatsbyJS
  • Prettier & Linters
  • Apollo Federation

Custom Code-Generator Plugins

  • What are Plugins?
  • Write your first Plugin
  • Validate Plugin Configuration
  • How to extend the GraphQL Schema?
  • Visitor Pattern

Migration

  • Migration to 1.0.0
  • Migration from 0.13 to 0.18

Schema AST

schema-ast plugin prints the merged schema as string. If multiple schemas are provided, they will be merged and printed as one schema.

Installation

$ yarn add -D @graphql-codegen/schema-ast

Examples

# ...
schema:
  - 'http://localhost:3000/graphql'
  - './src/**/*.graphql'
  - 'scalar MyCustomScalar'
generates:
  path/to/file.graphql:
    plugins:
      - schema-ast

Configuration

includeDirectives (boolean, default value: false)

Include directives to Schema output.

Usage Example

schema:
  - './src/schema.graphql'
generates:
  path/to/file.graphql:
    plugins:
      - schema-ast
    config:
      includeDirectives: true

commentDescriptions (boolean, default value: false)

Set to true in order to print description as comments (using # instead of """)

Usage Example

schema: http://localhost:3000/graphql
generates:
  schema.graphql:
    plugins:
      - schema-ast
    config:
      commentDescriptions: true

← TimeReason Client →
  • Installation
  • Examples
  • Configuration
GraphQL Code Generator
githubmediumtwitter
DocsHelp
© Copyrights by The Guild, all rights reserved
© The Guild 2018
GraphQL Code Generator is licensed under MIT and can be used free of charge with no restrictions