UNPKG

1.57 kBMarkdownView Raw
1# `graphql-codegen-cli`
2
3[Refer to full documentation, examples and more here](https://github.com/dotansimha/graphql-code-generator/blob/master/README.md)
4
5This package is the front-facing package of the code generator.
6
7It parses the CLI commands into a `GeneratorConfig` and `Settings` object, and also in charge of reading and writing files from the filesystem, and execute Introspection request to remote GraphQL endpoints.
8
9For a full CLI documentation, please refer to the main `README` file of the package.
10
11## `gql-gen.json`
12
13`gql-gen.json` is a local config file, provides a custom config when using custom templates.
14
15This is an example for a valid file:
16
17```json
18{
19 "flattenTypes": true,
20 "primitives": {
21 "String": "string",
22 "Int": "number",
23 "Float": "number",
24 "Boolean": "boolean",
25 "ID": "string"
26 },
27 "customHelpers": {
28 "myHelper": "./my-helper.js"
29 }
30}
31```
32
33You can override the config for `flattenTypes` and `primitives` (refer to `graphql-codegen-compiler` package README for more info).
34
35You can also specify JavaScript files for `customHelpers` when generating custom templates (the custom files should export a `Function` as default).
36
37### Generator Specific Config
38
39You can also pass configuration object to the output generator, by adding `generatorConfig` to the `gql-gen.json` file:
40
41```json
42{
43 "generatorConfig": {
44 "myConfig": "my value"
45 },
46 "flattenTypes": true,
47 "primitives": {
48 "String": "string",
49 "Int": "number",
50 "Float": "number",
51 "Boolean": "boolean",
52 "ID": "string"
53 }
54}
55```