Genql
Website

Quick Start#

Genql translate typed code into graphql queries, enabling you to get auto completion and validation for your graphql queries.

To use genql you first need to generate a sdk client, this can be done in 2 ways:

  • using the genql website to generate a client npm package for a public graphql api

  • using the @genql/cli package to generate code locally

Generate via UI#

Go to genql.now.sh and compile the form

Generate with the cli#

First install the required package from npm

bash
1
npm init -y
2
npm i -D @genql/cli # cli to generate the client code
3
npm i @genql/runtime graphql # runtime dependencies

@genql/cli is a dev dependency because it is only required to generate the client, @genql/runtime instead is a direct dependency of the generated code

Then run the genql command to generate the client inside a directory

bash
1
genql --schema ./schema.graphql --output ./generated
2
# or using a graphql api url
3
genql --endpoint https://countries.trevorblades.com --output ./generated -H 'Authorization: Bearer myToken'

Using the client#

The generated files expose a function createClient, this creates a client you can use to send requests

Read more about the graphql client methods in the usage section

Quick Start