The Guild LogoThe Guild Monogram
Docs

GraphQL Code Generator

Generate anything from GraphQL schema / operations!

Contact Us

Installation#

Installing Codegen#

Make sure that you add both the graphql and @graphql-codegen/cli packages in your project's dependencies:

yarn add graphql yarn add @graphql-codegen/cli

GraphQL Code Generator comes with dozen plugins, from front-end to back-end, from web apps to mobile apps. If you are not sure which plugins might be helpful for your GraphQL stack, give a try at the Initialization Wizard.

Otherwise, you can start exploring the plugins and setting up them manually.

 


 

Setup#

Initialization Wizard#

Once installed, GraphQL Code Generator CLI can help you configure your project based on some popular flows:

yarn graphql-codegen init yarn install # install the choose plugins

Question by question, it will guide you through the whole process of setting up a schema, selecting and installing plugins, picking a destination to where your files are generated, and a lot more.

npx

The init process above can also be run through npx.

Manual Setup#

Once GraphQL Code Generator is installed and added to your project's development workflow (scripts), you can start installing plugins and configuring them.

If you are looking for the best way to leverage GraphQL Code Generator on your stack, you should read one of our Guides.

On top of each plugin documentation, we provide one Guide for the most famous framework such as React or Apollo Server. Each guide exposes the best plugins and configurations available for each framework and stack (React with Apollo / URQL / React Query, Angular with Apollo, ...).


Otherwise, if you prefer exploring plugins and skipping the high-level explanations, the go-to resource will be the plugins documentation and the codegen.yaml API reference documentation.