Configuration
Grats has a few configuration options. They can be set under the "grats"
key in your in your project's tsconfig.json
file:
{
"grats": {
// Config options go here. See below:
},
"compilerOptions": {
// ... TypeScript config...
}
}
Options
All configuration options are optional. Below is a list of all available options, their types, descriptions, and default values.
"graphqlSchema": string
Where Grats should write your schema file. Path is relative to the `tsconfig.json` file.
"./schema.graphql"
"tsSchema": string
Where Grats should write your executable TypeScript schema file. Path is relative to the `tsconfig.json` file.
"./schema.ts"
"tsClientEnums": string | null
Where Grats should write your TypeScript enums file. Path is relative to the `tsconfig.json` file.
If enabled, Grats will require that all GraphQL enums be defined using exported TypeScript enums. Set to `null` to disable emitting this file.
""
"nullableByDefault": boolean
Should all fields be typed as nullable in accordance with GraphQL best practices?
https://graphql.org/learn/best-practices/#nullability
Individual fields can declare themselves as non-nullable by adding the docblock tag `@killsParentOnException`.
true
"strictSemanticNullability": boolean
Experimental feature to add `@semanticNonNull` to all fields which have non-null TypeScript return types, but which are made nullable by the `nullableByDefault` option.
This feature allows clients which handle errors out of band, for example by discarding responses with errors, to know which fields are expected to be non-null in the absence of errors.
See https://grats.capt.dev/docs/guides/strict-semantic-nullability
It is an error to enable `strictSemanticNullability` if `nullableByDefault` is false.
false
"reportTypeScriptTypeErrors": boolean
Should Grats error if it encounters a TypeScript type error?
Note that Grats will always error if it encounters a TypeScript syntax error.
false
"schemaHeader": string | string[] | null
A string to prepend to the generated schema text. Useful for copyright headers or instructions for how to regenerate the file. Set to `null` to omit the default header.
# Schema generated by Grats (https://grats.capt.dev) # Do not manually edit. Regenerate by running `npx grats`.
"tsSchemaHeader": string | string[] | null
A string to prepend to the generated TypeScript schema file. Useful for copyright headers or instructions for how to regenerate the file. Set to `null` to omit the default header.
/** * Executable schema generated by Grats (https://grats.capt.dev) * Do not manually edit. Regenerate by running `npx grats`. */
"tsClientEnumsHeader": string | string[] | null
A string to prepend to the TypeScript enums file generated when the `tsClientEnums` configuration options is set. Useful for copyright headers or instructions for how to regenerate the file. Set to `null` to omit the default header.
/** * TypeScript enum definitions generated by Grats (https://grats.capt.dev) * Do not manually edit. Regenerate by running `npx grats`. */
"importModuleSpecifierEnding": string
This option allows you configure an extension that will be appended to the end of all import paths in the generated TypeScript schema file.
When building a package that uses ES modules, import paths must not omit the file extension. In TypeScript code this generally means import paths must end with `.js`. If set to null, no ending will be appended.
""
"EXPERIMENTAL__emitMetadata": boolean
EXPERIMENTAL: THIS OPTION WILL BE RENAMED OR REMOVED IN A FUTURE RELEASE
Emit a JSON file alongside the generated schema file which contains the metadata containing information about the resolvers.
false
"EXPERIMENTAL__emitResolverMap": boolean
EXPERIMENTAL: THIS OPTION WILL BE RENAMED OR REMOVED IN A FUTURE RELEASE
Instead of emitting a TypeScript file which creates a GraphQLSchema, emit a TypeScript file which creates a GraphQL Tools style Resolver Map.
https://the-guild.dev/graphql/tools/docs/resolvers#resolver-map
false