Grats has a few configuration options. They can be set under the "grats" key in your in your project's tsconfig.json file:
tsconfig.json
{
"grats": {
// Config options go here. See below:
},
"compilerOptions": {
// ... TypeScript config...
}
}All configuration options are optional. Below is a list of all available options, their types, descriptions, and default values.
Where Grats should write your schema file. Path is relative to the tsconfig.json file.
Default: "./schema.graphql"
Where Grats should write your executable TypeScript schema file. Path is relative to the tsconfig.json file.
Default: "./schema.ts"
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.
Default: ""
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.
Default: true
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.
Default: false
Should Grats error if it encounters a TypeScript type error?
Note that Grats will always error if it encounters a TypeScript syntax error.
Default: false
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.
Default:
# Schema generated by Grats (https://grats.capt.dev)
# Do not manually edit. Regenerate by running npx grats.
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.
Default:
/**
\ * Executable schema generated by Grats (https://grats.capt.dev)
\ * Do not manually edit. Regenerate by running npx grats.
*/
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.
Default:
/**
\ * TypeScript enum definitions generated by Grats (https://grats.capt.dev)
\ * Do not manually edit. Regenerate by running npx grats.
*/
The extension appended to the end of all import paths in the generated TypeScript schema file. Defaults to .js which works for both CommonJS and ES module projects. Set to an empty string to omit the extension.
Default: ".js"
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.
Default: false
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
Default: false