The Guild LogoThe Guild Monogram

Search docs

Search icon

Products by The Guild

Products

Hive logoHive blurred logo

Hive

Schema Registry for your GraphQL Workflows

Docs

GraphQL Code Generator

Generate anything from GraphQL schema / operations!

Contact Us

Prettier & Linters#

The codegen supports lifecycle hooks, and you can use those for integration with Prettier or other linters, to apply your custom code-style and formatting rules. Before adding hooks consider the alternative of having codegen ignored in your linting. Codegen files are not edited manually and formatting them slows down your codegen considerably. On a big project difference can be measured in several seconds for every run.

You can read the complete documentation of lifecycle hooks here

Prettier#

You can run it per each file:

hooks: afterOneFileWrite: - prettier --write

Or, for all files together:

hooks: afterAllFileWrite: - prettier --write

Prefer this method if you're using near-operation-file preset as this has better performance when writing many files.

TSLint#

You can run it per each file:

hooks: afterOneFileWrite: - tslint --fix

Or, for all files together:

hooks: afterAllFileWrite: - tslint --fix

ESLint#

hooks: afterOneFileWrite: - eslint --fix

Or, for all files together:

hooks: afterAllFileWrite: - eslint --fix