Docs

Get Started

CLI Configuration#

The CLI looks for 3 places of configuration files/property, in this respective order:

  1. gqty.config.cjs
  2. gqty.config.js
  3. gqty property inside package.json

And since it's using cosmiconfig to resolve it, if you are using GQty in a monorepo, having it in the root of your monorepo might be enough 🎉.

Default Config#

The default configuration file, which is automatically generated after the first execution of gqty generate, should look like this:

/** * @type {import("@gqty/cli").GQtyConfig} */ const config = { enumsAsStrings: false, react: true, scalarTypes: { DateTime: 'string' }, preImport: '', introspection: { endpoint: 'SPECIFY_ENDPOINT_OR_SCHEMA_FILE_PATH_HERE', headers: {}, }, destination: './src/gqty/index.ts', subscriptions: false, }; module.exports = config;

Properties#

NameTypeDescription
enumsAsStringsbooleanWhether to use enums as simple string types, or as the default Object String Enums of TypeScript.
reactbooleanWhether to add the React bindings to the first-generated client.
scalarTypesRecord<string,string>Mapping of Custom Scalar Types to TypeScript, since by default, any custom scalar will be casted as any.
preImportstringCode to be added at the very beginning of the generated schema file, useful for adding custom imported types in custom scalars.
introspection.endpointstringEndpoint from where the introspection of the target GraphQL API, it can be an http/https endpoint, or the path of a .gql GraphQL schema file.
introspection.headersRecord<string,string>Custom headers to be added to http/https introspection, normally for authorization purposes.
destinationstringFile destination of the generated client. Keep in mind that the generated schema always will be alongside this destination, but named schema.generated.ts.
subscriptionsbooleanWhether to add Subscriptions support to the client.
transformSchema(schema: GraphQLSchema, graphql_js: import("graphql")) => Promise<GraphQLSchema> | GraphQLSchemaTransform the GraphQL Schema before being used to generate the client