Fauna is a distributed document-relational database delivered as a cloud API. It allows you to build new or migrate existing applications to Fauna and scale without worrying about operations.
WunderGraph makes it possible for your application to use its own dedicated BFF while allowing code sharing across all your applications, while preventing credentials and API keys from leaking into the browser.
With WunderGraph, you can structure your Public API as operations. Every operation is a GraphQL file with a single GraphQL query or mutation that the BFF exposes using JSON-RPC (HTTP). This approach hides unnecessary complexity from designing a cacheable and secure public API with GraphQL.
We've included a quick guide that demonstrates how to integrate Fauna as a data source into a WunderGraph application in under ~10 minutes 👀 . The procedure uses the WunderGraph open source "monorepo," which has a dedicated example for Fauna as a data source.
Log in to the Fauna Dashboard
Click the [CREATE DATABASE] button.
Enter a name for your database. For example: wundergraph
Select an appropriate Region Group
Check the Use demo data checkbox.
Click the [CREATE] button.
When you complete these steps, you have a database that has several collections of documents, several indexes, and a configured GraphQL API with a matching schema definition. The sample data allows you to experiment with various CRUD queries and mutations.
Click the [ Security ] button in the left navigation pane.
Click the [ NEW KEY ] button.
Click the [ SAVE ] button.
Store the displayed secret in a safe place.
The Dashboard only shows a secret once. When you complete these steps, you have a Fauna secret that grants access to use the associated database.
git clone https://github.com/wundergraph/wundergraph.git
cd wundergraph/examples/faunadb-nextjscp example.env .env
2. Edit the file .env to replace <replace-with-your-token> with the secret for the admin key that you stored as part of Step 2: Create a key with the admin role
3.If you selected a Region Group other than Classic, edit the file .env to replace https://graphql.fauna.com/graphql with the GraphQL API endpoint suitable for your selected Region Group:
npm install && npm start
When you run the command, you should see the dependency installation progress followed by the start of the application. Your web browser should open http://localhost:3000 and display the result of the AllStores operation:
> Create( Ref(Collection("stores"), "304"), { data: { name: "My Personal Bodega", address: { street: "1234 My Street", city: "My City", state: "WA", zipCode: "90210" } } })
3. Click the [ RUN QUERY ] button.
4. In the WunderGraph application, click the [ Refresh ] button. You should see that the list of stores now has the new _id field 304.
5. Type Control + C to exit the WunderGraph application.
Now that the WunderGraph application is configured, look at the generated integration code in .wundergraph/wundergraph.config.ts. You should see that adding Fauna as a data source is only eight lines of code. You can also review the file in the .wundergraph/operations folder to see the AllStores query.
The demonstration application is simple: only one operation is defined. But it shows how easy it is to safely expose Fauna to your front-end application using WunderGraph. You can extend the demonstration application, or start your own using similar configuration steps. Learn more in the WunderGraph documentation .
We'd like to thank the amazing team at Fauna for collaborating with us on this integration. A special thank you to Nishant Madichetti, Zee Khoo, Matt Slagle, and Wyatt Wenzel! We look forward to future collaboration and providing our users with an unmatched serverless developer experience with Fauna and WunderGraph Cloud 👀
Our goal with WunderGraph is to make Developers highly productive in building Serverless APIs. So far, we've built an open-source Framework that's designed to be local-first, transparent, and easy to debug.
To make WunderGraph scalable, we've designed it with GitOps in mind. Everything is configured with TypeScript, allowing individuals and teams to share their configurations and customizations using git.
The next step for us is to automate continuous deployment to the cloud. With WunderGraph Cloud, you can connect your git repositories with a few clicks and deploy them to our Serverless Cloud.
To get early access, You can sign up for our waitlist
There are so many ways you can support us here at WunderGraph. Tweet at us. Star us on Github. Post in our Discord! or Build something with our latest integration and show us so we can share it!
Thoughts or questions?
We would love to hear from you!