Skip to main content

Getting started


  1. Go to the root of your project, and run:
    npm install gqless
    npm install -D @gqless/cli graphql
  2. Next, add a script field to your package.json:
    "scripts": {
    "generate": "gqless generate"
  3. Then run the script once, to create a gqless.config.cjs file:
    npm run generate

Configuring Codegen#

The default config should look something like this:

can also be specified in package.json via gqless key

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

Point introspection.endpoint to your GraphQL API, adding headers for authorization if necessary. Then run the generate command again, to fetch your schema and output to the destination file:

npm run generate

The output should look like this:

โ”œโ”€โ”€ schema.generated.ts # Will be overwritten when you codegen again
โ””โ”€โ”€ index.ts # GQless client is exported from here, safe to modify options

Getting started#

Configure the fetch() call to your GraphQL server, located inside the queryFetcher() method within src/gqless/index.ts. You might for instance want to dynamically generate the URL depending on environment, or connect it up to your apps authorization.


See one of the following for more:

Using with React#

Using the standalone Client#

Last updated on by github-actions[bot]