The Guild LogoThe Guild Monogram

Search docs

Search icon
Skip to main content

codegen

Generate code from your GraphQL schema and operations. See the official GraphQL Code Generator site for complete documentation, guides and more.

Installation#

yarn global add @graphql-cli/codegen

Note: GraphQL Code Generator also utilizes a plugin system, so make sure you also install any plugins you include inside your configuration. See here for a list of plugins.

Example Configuration#

schema:  - http://localhost:4000/graphqlextensions:  codegen:    generates:      ./graphql.schema.json:        plugins:          - "introspection"

See the docs for more details.

Usage#

graphql codegen

Arguments#

None

Options#

optionaliasdescriptiondefault
--config-cPath to GraphQL codegen YAML config filecodegen.yml or GraphQL configuration file in cwd
--watch-wWatch for changes and execute generation automatically. You can also specify a glob expreession for custom watch list.
--require-rLoads specific require.extensions before running the codegen and reading the configuration[]
--overwrite-oOverwrites existing filestrue
--silent-sSuppresses printing errorsfalse
--project-pName of a project in GraphQL Configundefined