...

/

Setting Up GraphQL Code Generator

Setting Up GraphQL Code Generator

Learn how to install and run GraphQL Code Generator.

Adding GraphQL Code Generator to dependencies

The GraphQL Code Generator maintainers have provided us with a package that helps us get started quickly. This package is called graphql-codegen/cli. Let’s add the @graphql-codegen/cli package to our client application with the following command:

yarn add -D @graphql-codegen/cli

Alternatively, we can manually add the @graphql-codegen/cli package to our package.json file under devDependencies:

"@graphql-codegen/cli": "2.3.0"

Running yarn install inside the application’s directory will install this package.

Configuring GraphQL Code Generator

This @graphql-codegen/cli package gives us a new command to use called graphql-codegen. We will run it to set up the GraphQL Code Generator. We can run the following command ...