codegen
Generate code from your GraphQL schema and operations. See the official GraphQL Code Generator site for complete documentation, guides and more.
#
Installation- yarn
- npm
yarn global add @graphql-cli/codegen
npm i -g @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 Configurationschema: - http://localhost:4000/graphqlextensions: codegen: generates: ./graphql.schema.json: plugins: - "introspection"
See the docs for more details.
#
Usagegraphql codegen
#
ArgumentsNone
#
Optionsoption | alias | description | default |
---|---|---|---|
--config | -c | Path to GraphQL codegen YAML config file | codegen.yml or GraphQL configuration file in cwd |
--watch | -w | Watch for changes and execute generation automatically. You can also specify a glob expreession for custom watch list. | |
--require | -r | Loads specific require.extensions before running the codegen and reading the configuration | [] |
--overwrite | -o | Overwrites existing files | true |
--silent | -s | Suppresses printing errors | false |
--project | -p | Name of a project in GraphQL Config | undefined |