CLI Commands
The commands below can be used with the Grafbase CLI.
You use the init
command to initialize a new project, or existing project.
cd my-project
npx grafbase init
The init
command will create the new directory grafbase
that contains your schema, environment variables, and more.
You can use the following flags when invoking init
:
--template
— The name or GitHub URL of the template to use for the new project.
npx grafbase init --template blog
You use the dev
command to start the local Grafbase server.
npx grafbase dev
You can then visit the following URLs to access:
- Playground —
http://localhost:4000
- API —
http://localhost:4000/graphql
You can override the default behaviour of dev
by passing various flags.
--port PORT
— Set a different port the server runs on. Defaults to4000
.--disable-watch
— Disable restarting the server when a change to your schema is detected.
You should use the login
command to authenticate with your Grafbase account so you can create and deploy projects without leaving the CLI.
npx grafbase login
You will be redirected to the Grafbase Dashboard to verify linking your account.
You should configure the environment variable GRAFBASE_ACCESS_TOKEN
for use inside of CI/CD, such as GitHub Actions.
You should use the create
command to create a new Grafbase project.
You should give your project a name and select the account/organization it belongs to.
Your project will be deployed automatically once created.
npx grafbase create
You can pass the following flags with the create
command:
-n, --name <name>
— The name for the new project.-a, --account <slug>
— The slug of the account in which the new project should be created.-r, --regions <region>
— The regions in which the database for the new project should be created.
You should use the deploy
command to redeploy an existing project.
npx grafbase deploy
You can use the reset
command to reset your project data:
npx grafbase reset
This does the same as deleting the .grafbase
directory.
You can use the help
command to list the available commands and options, as well as the installed version details.
npx grafbase help