Skip to main content

CLI Configuration

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

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

And since it's using cosmiconfig to resolve it, if you are using GQless 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 gqless generate, should look like this:

/**
* @type {import("@gqless/cli").GQlessConfig}
*/
const config = {
enumsAsStrings: false,
react: true,
scalarTypes: { DateTime: 'string' },
preImport: '',
introspection: {
endpoint: 'SPECIFY_ENDPOINT_OR_SCHEMA_FILE_PATH_HERE',
headers: {},
},
destination: './src/gqless/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.

Last updated on by Pablo Sáez