Build and Deploy a GraphQL API to the Edge with Fauna — Part 3
Install and configure Fauna inside Grafbase Resolvers
Let's begin by installing the Fauna JavaScript driver inside our project so that we can use it inside our first resolver:
npm install fauna graphql
Now create the file grafbase/resolvers/create.ts
.
We'll complete this inside the next step but for now, we can import Fauna and initialize a new client
:
import { Client, fql, FaunaError } from "fauna";
const client = new Client();
💡
Fauna automatically detects the environment variable
FAUNA_SECRET
. If you name it something else, you'll need to pass it to Client()
.That's it!