@nanolier/typescript-graphql-schema-type-generator
v0.0.7
Published
## ๐ CLI tool to create Type Alias for TypeScript from GraphQL schema
Downloads
595
Readme
Typescript Graphql Schema Type Generator
๐ CLI tool to create Type Alias for TypeScript from GraphQL schema
Getting Started
Install
Install the library.
npm i -D @nanolier/typescript-graphql-schema-type-generator
Add to scripts in package.json.
{
"scripts": {
"tgstgen": "tgstgen"
}
}
Create Type Alias File
npm run tgstgen
By default, "./schema.graphql" is read and "./src/__generated__/schema.graphql.ts". To change this, specify the file to be read and the output destination as arguments when executing the command.
npm run tgstgen --schema=.example-dir/schema.gql --output=./example-dir/__generated__/schema.graphql.ts
or
{
"scripts": {
"tgstgen": "tgstgen --schema=.example-dir/schema.gql --output=./example-dir/__generated__/schema.graphql.ts "
}
}
CLI Options
schema
The relative path to the GraphQL schema file to be used.
tgstgen --schema=.example-dir/schema.gql
output
The relative path to the TypeScript type file to be generated.
tgstgen --schema=.example-dir/schema.gql
nullableType
When nullableType=relay, nullable values will have the type null | undefined. When nullableType=relay-classic, nullable values will have the type null only.
tgstgen --nullableType=relay
noFutureProofEnums
When set to true, the generated enum types will include a %future added value.
tgstgen --noFutureProofEnums=true
onlyEnum
When set to true, only the enum types will be generated.
tgstgen --onlyEnum=false