Grafbase CLI

The Grafbase CLI provides a fully working local Grafbase environment, without the need to install Docker.

You should use the Grafbase CLI when building apps locally.

You can use the init command to initialize a new Grafbase project:

npx grafbase init

Use the dev command to start the server locally at http://localhost:4000:

npx grafbase dev

The Grafbase CLI can be installed globally using NPM, Yarn, Cargo, or as a binary.

npm install -g grafbase

You should use the GRAFBASE_ACCESS_TOKEN environment variable within CI environments where the value is an access token.

# .github/workflows/grafbase.yml # name: Grafbase on: push: branches: - main jobs: main: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: 'lts/*' check-latest: true cache: 'npm' - name: Deploy run: npx grafbase deploy env: GRAFBASE_ACCESS_TOKEN: ${{ secrets.GRAFBASE_ACCESS_TOKEN }}

You can configure the directory where the global .grafbase is stored using the flag --home or the GRAFBASE_HOME environment variable within your system or CI.

GRAFBASE_HOME=custom-dir npx grafbase init

Note: --home takes precedence over GRAFBASE_HOME if both are specified, and both override the default user home directory.

Grafbase gathers anonymous usage data to enhance the CLI experience for local development.

It is important to note that Grafbase does not collect any personally identifiable information (PII), local data, schemas or values passed to the CLI arguments.

To opt out, you have two options:

  1. inside $HOME/.grafbase/config.json set the following:
{ "analyticsEnabled": false, "anonymousId": null }
  1. Set the system environment variable DO_NOT_TRACK=1DNT
Was this page helpful?