Grafbase: Instant serverless GraphQL backends
Tags: graphql, serverless, grafbase, webassembly
Published: 2022-07-28 12:15:00

As a developer, you are faced with many decisions before your backend is ready for use. What API framework do you use? What database? Where do you deploy your API? Where do you deploy your database? Authorization? What about full-text search? And message queue? We haven't even talked about local development or CI/CD yet. The time to market from idea to production is much longer than it has to be.

**We can do better.**

We are very excited to announce **Grafbase**, an edge-native data platform for developers. Our mission is to dramatically simplify and accelerate the development of GraphQL backends.

Grafbase combines GraphQL, Serverless, and Edge Computing to provide a seamless developer experience for shipping backends. Go from idea to serverless GraphQL backend in seconds without spending time on infrastructure.

## Getting Started

Run the following command in a new directory:

```
npx grafbase init
```

Then populate `grafbase/schema.graphql` with this schema:

```graphql
type Todo @model {
  id: ID!
  title: String!
  complete: Boolean!
}
```

To start your local development environment run this command:

```
npx grafbase dev
```

You can interact with your GraphQL API using the Playground, which runs on [http://localhost:4000](http://localhost:4000) by default.

Create a new Todo:

```graphql
mutation {
  todoCreate(input: { title: "Hello, world!", complete: false }) {
    todo {
      id
      title
      complete
    }
  }
}
```

Congratulations! You have just built your first Todo GraphQL backend.

## GraphQL

Frontend and mobile developers love GraphQL. However, building a performant and flexible GraphQL backend can be difficult and time-consuming.

There have been attempts at modernizing GraphQL backend development by building an interface on top of traditional databases. However, this approach involves complex infrastructure, which is asking too much from the developer and takes away from valuable time that could be spent shipping their product.

Grafbase lets you design your GraphQL backend using a declarative approach and watch it come to life in a matter of seconds.

Use powerful GraphQL directives to define models, permissions, caching, validation, and more.

Grafbase will vastly reduce your time to market.

Another benefit of using GraphQL is that you can use any GraphQL client or SDK that you already know.

Your architecture is also vastly simplified since you no longer need to deploy a proxy in front of your traditional database or deal with connection pooling since your backend is served from a GraphQL endpoint via HTTP.

## Livin' on the Edge

Jamstack websites are globally fast thanks to pre-rendered content delivered by CDNs. However, dynamic content is predominantly served from APIs deployed to a single region, resulting in suboptimal response times everywhere else.

The Grafbase platform runs on a global edge network to achieve fast response times globally.

To further improve performance, we are planning to offer edge caching for all GraphQL APIs deployed to Grafbase.

GraphQL APIs deployed to Grafbase run on V8 isolates, which means no cold starts. V8 isolates give you the freedom to build your backend using JavaScript or any language that compiles to WebAssembly.

## WebAssembly

WebAssembly (Wasm) offers near-native performance with a sandboxed security model and is portable - making it a perfect technology for hosting a GraphQL API at the edge.

Thanks to Wasm and its security model, we allow developers to write business logic in the form of GraphQL resolvers in their language of choice.

Are you an iOS developer and want to code in Swift? An Android developer who loves Kotlin? A Jamstack developer that prefers Deno? The promise of portability is finally here thanks to server-side Wasm.

## Jamstack

The Jamstack has removed multiple moving parts and systems to make websites easy to deploy with fast page load times thanks to pre-rendered content delivered by CDNs. In addition, the abstraction layer that the Jamstack and CDNs have provided makes it much easier to ship a static website. But when your application requires dynamic functionality beyond a static page and you need a backend - creating that backend is still not as simple as it should be.

## Battle-Tested

Grafbase stands on the shoulders of giants like Cloudflare and AWS to ensure our infrastructure is reliable, performant, and predictable. This lets us focus our energy on building the best developer experience for building and deploying GraphQL backends that scale from startups to enterprises.

The Grafbase platform is built with Rust and runs on rock-solid serverless infrastructure like Cloudflare Workers and DynamoDB. This enables us to offer incredible P99 performance guarantees from day one.

## Serverless

On-demand infrastructure and usage-based pricing are the future. However, the tooling and developer experience to adopt serverless is still in the dark ages.

Cloud services like Cloudflare Workers and AWS DynamoDB are very powerful, but the DX is lacking. Grafbase aims to change that by building higher-level abstractions with a developer-first mindset.

Projects deployed to Grafbase come with a globally replicated serverless database seamlessly integrated into every GraphQL API.

Grafbase will offer usage-based pricing that scales to zero. This means you can have hundreds of preview environments for your backend at very low cost.

## Local Development

We're building Grafbase with a developer-first mindset to remove friction and make backend development seamless.

`npx grafbase dev` gives you a zero config local environment that simulates production.

The local development environment hot reloads when detecting changes to files in the `grafbase` directory for fast iteration of your GraphQL API.

The Grafbase CLI is written in Rust and open-sourced on [GitHub](https://github.com/grafbase/grafbase/tree/main/cli).

## Branching

Grafbase is deeply integrated with GitHub to provide a modern Git-based workflow for backend development.

Branches are instantly provisioned on serverless infrastructure with production parity.

Deployments take 3 seconds from Git push to live, which enables blazing fast iteration of your backend in isolation before deploying to production.

If you use Vercel or Netlify today, you're already used to this workflow. We were inspired by this approach and offer similar functionality at Grafbase, but geared towards backend development.

## What's Next

Over the coming months, we will be working closely with the community to make Grafbase the best platform to build and deploy instant serverless GraphQL backends.

Grafbase is currently in private beta. Sign up for the Private Beta [here](https://grafbase.com/join-the-waitlist).

Read our [Documentation](https://grafbase.com/docs). Check out the [Changelog](https://grafbase.com/changelog). Follow us on [Twitter](https://twitter.com/grafbase) and [GitHub](https://github.com/grafbase). Join our [Community](https://grafbase.com/community).