Build and Deploy a GraphQL API to the Edge with Fauna โ€” Part 1

Jamie BartonJamie Barton
2 min read

In this series, we will build a GraphQL API with Grafbase, and persist data with Fauna.

Here's a breakdown of what we'll be building:

  1. This is part 1

  2. Set up a Fauna Database

  3. Install and configure Fauna inside Grafbase Resolvers

  4. Create Product Mutation

  5. Update Product Mutation

  6. Delete Product Mutation

  7. Fetch Product by ID or Unique field Query

  8. Fetch all Products Query

  9. Enable edge caching to reduce database calls

  10. Deploy to the Edge with GitHub

Grafbase

Grafbase simplifies the process of creating and implementing your personalized GraphQL API at the edge while ensuring complete end-to-end type safety.

By using resolvers and connectors, Grafbase allows seamless integration with any data source. Additionally, you can take advantage of features such as edge caching, authentication and permission rules configuration, serverless search functionality, and more.

Grafbase's versatility extends to local development as well, thanks to the Grafbase CLI. Each Git branch has its preview deployment, facilitating convenient testing and collaboration.

Fauna

Fauna is a highly scalable and flexible globally distributed serverless database. It's ideal for businesses offering multi-tenant services with nested databases. Fauna supports ACID transactions for reliable and secure data operations.

Fauna also provides fine-grained access control for controlled data access. With built-in GraphQL support, Fauna simplifies the development of GraphQL-powered applications by automatically generating schemas.

1. Set up Grafbase

Begin by creating a new Grafbase project. If you have an existing frontend that you want to create a GraphQL API, you must run the following command inside that project directory:

npx grafbase init graphql-fauna-api

This command will ask if you want to create a project using GraphQL SDL or TypeScript.

๐Ÿ’ก
This guide will use TypeScript to configure all queries, mutations, types and input types.

That's it! You now have a Grafbase project set up and ready to use. We'll learn how to deploy this to Grafbase at the edge at the end of this series.

Continue to Part 2 ๐Ÿ‘‰

0
Subscribe to my newsletter

Read articles from Jamie Barton directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Jamie Barton
Jamie Barton