- Use
graphql-codegen
to generate code from GraphQL Schemas.
Using pnpm:
pnpm add -D nx-graphql-codegen
Using npm
npm install -D nx-graphql-codegen
Using yarn
yarn add -D nx-graphql-codegen
Name | Version | Required |
---|---|---|
nx |
>=15.7.1 |
✅ |
@graphql-codgen/cli |
>=2.16.1 |
✅ |
Run graphql-codegen.
"targets": {
"codegen": {
"executor": "nx-graphql-codegen:codegen",
"options": {
"config": "libs/my-lib/codegen.ts",
},
},
}
codegen executor options
Name | Type | Required | Default | Description |
---|---|---|---|---|
config |
string |
✅ | - | Path to GraphQL codegen YAML config file, defaults to codegen.yml on the current directory. |
debug |
boolean |
- | false |
Display debugging info by applying the DEBUG env variable. |
overwrite |
boolean |
- | true |
Overwrites existing files. |
profile |
boolean |
- | false |
Use profiler to measure performance. |
project |
string |
- | `` | Name of a project in GraphQL Config. |
require |
string[] |
- | [] |
Loads specific require.extensions before running the codegen and reading the configuration. |
silent |
boolean |
- | false |
Suppresses printing errors. |
watch |
boolean |
- | false |
Watch for changes and execute generation automatically. |
Generate a target to run a graphql-codegen.
nx generate nx-graphql-codegen:codegen dev --project=my-app --config='packages/my-lib/codegen.ts'
codegen generator output
> NX Generating nx-graphql-codegen:codegen
UPDATE libs/my-lib/project.json
codegen generator options
Name | Alias | Type | Required | Default | Description |
---|---|---|---|---|---|
config |
- | string |
✅ | - | Path to GraphQL codegen YAML config file, defaults to codegen.yml on the current directory. |
name |
- | string |
✅ | - | Target name. |
project |
- | string |
✅ | - | What project does the target belong to? |
Name | Path |
---|---|
typescript-operations | examples/typescript-operations |
nx-graphql-codegen |
Nx |
---|---|
^0.0.0 |
^15.7.1 |
This plugin wouldn't be possible without the great teams behind these projects:
- The Guild - The team behind GraphQL Codegen.
- Nrwl - The team behind Nx
Please show them your support! ❤️
🌳 🦌 🌳