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 = {
endpoint: '/api/graphql',
enumsAsStrings: false,
react: true,
scalars: { 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
endpointstringEndpoint used in the first-generated client, you are free to change it in there, and this config will be ignored.
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.
scalarsRecord<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 Sam Denty