September 29, 2023

How to Set Up A Serverless GraphQL Backend on 8base in 4 Steps

8base
@8base

8base's backend-as-a-service removes the hassle of manual infrastructure management, enabling front-end developers to focus more on what they love and back-end developers to expedite their workflows.

In this guide, we’ll walk you through the process of setting up a serverless GraphQL backend on 8base, allowing you to build fast, efficient and scalable APIs for your application.

In This Walkthrough, We Will

  • Set up a project in 8base and build a simple data model that we’ll reference with a frontend request
  • Illustrate how to make a request to your backend

Prerequisites

Before we get started, you’ll need a free 8base account. The process to sign up is simple: sign up here with your email and password, and confirm your account via email.

Once your account is confirmed, you’ll be redirected to a default project. This project will serve as the foundation for your serverless GraphQL backend and can be connected to one of 8base’s starter applications or your own frontend application.

1. Set Up Your Project

Each project is treated individually in 8base, similar to having separate Git repositories for different code bases. This approach makes it easy to stay organized and upgrade individual projects as your app or service scales.

Creating a new project in 8base is a breeze. Simply follow these steps:

  1. Click on the “YOUR NAME’s Project” dropdown at the top of your screen.
  2. Select “+ New Project”.
  3. Provide a name for your new project.
  4. Click “Create”.
  5. In less than 10 seconds, your new project should be loaded and ready to go.

2. Create a Data Model

<iframe width="800" height="450" src="https://www.youtube.com/embed/JIEG3oL-iHs" title="8base Academy - Defining Data Tables and Relationships in the Data Builder - Course 2" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>

Once your project is ready, you can begin designing and creating data models using 8base’s Data Builder. Accessible through our backend UI, Data Builder is a powerful tool that allows you to define tables and fields for your serverless GraphQL backend.

In the project, head to the Data Builder page and click on [+ Create Table]. For demonstration purposes, we're going to create a table and name it Notes for our data model with the following fields.

Notes

Field          Type          Description             Options

title            Text           The notes title        mandatory=True

body          Text           The notes body      mandatory=True

3. Add a Row to Your Table

Next, let’s click the “Data” tab and add a row. We can call the title “Hamlet” and body, “A play about Denmark”.

4. Make a Request to Your Backend

As we mentioned above, it’s possible to use 8base as a backend-as-a-service when you connect your application to the 8base backend using the project API. This creates a very clear separation between the server-side (8base) and client-side (an app / frontend).

However, 8base really shines when you use its frontend App Builder to create a versatile full-stack application on the platform.

To make a request to your backend from App Builder, simply navigate back to the project dashboard and click to open the Frontend UI. Next,

  1. To add a new request to your backend, click the “Requests” icon on the lefthand navigation.
  2. Click the + icon to add a new request
  3. Here, you can make requests using either a query or mutation. For this demonstration, let’s add the following query to fetch the “title” and “body” fields from our Notes table:

    {
        Notes {
        title
        body
      }
    }

You now have your backend data flowing into the application.

Next steps

Congratulations! You’ve successfully set up a serverless GraphQL backend using 8base and connected it to your frontend application. Now that you have a solid foundation, it's a great time to dive into 8base's documentation, including:

With the power of serverless GraphQL backends at your fingertips, the sky’s the limit for your app’s potential.

To Learn More about Using 8base Low Code

Ready to try 8base?

We're excited about helping you achieve amazing results.