0.0.8 • Published 9 months ago
@nanolier/typescript-graphql-schema-type-generator v0.0.8
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-generatorAdd to scripts in package.json.
{
"scripts": {
"tgstgen": "tgstgen"
}
}Create Type Alias File
npm run tgstgenBy 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.gqloutput
The relative path to the TypeScript type file to be generated.
tgstgen --schema=.example-dir/schema.gqlnullableType
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=relaynoFutureProofEnums
When set to true, the generated enum types will include a %future added value.
tgstgen --noFutureProofEnums=trueonlyEnum
When set to true, only the enum types will be generated.
tgstgen --onlyEnum=false