Deploy your backend

Youtube video thumbnail

Until now we've been working with Grafbase locally using the CLI, which is great for development! However, we now want to share with others the URL to our backend.

Grafbase takes care of deploying and distributing your GraphQL API to the Edge by inspecting your grafbase/schema.graphql file.

To deploy to Grafbase you will need:

  • A GitHub account
  • A Grafbase account

Once logged into GitHub you can create a new repository.

Create new GitHub repo

Once you've created a repo, make sure to make note of the origin URL. We'll need that next.

GitHub empty repo

We'll now initialize Git inside of our local basenews folder and "commit" our schema.

git init
git add grafbase/schema.graphql
git commit -m "initial schema"

Then we'll need to add the remote origin that matches the URL provided by GitHub:

git branch -M main
git remote add origin ORIGIN_URL
git push -u origin main

You should now see your project schema on GitHub!

GitHub

You must now create an account or sign-in with Grafbase to import a new repository.

From here you must connect with GitHub to search for the repository you created above. Once you find the project you're looking for, click Import!

Import repository

Now you can set the Grafbase project name, as well as the branch we want to deploy. Let's use the same name as our GitHub repository, and right now, we only have one branch — main.

Deploy Grafbase Project

Now all that's left to do is click Deploy and Grafbase will generate a GraphQL API and deploy it to the edge in seconds.

Your projects dashboard will be updated to include some details about the deployment. We'll later explore connecting and authenticating with our API.

Deployed Grafbase Project

Was this page helpful?