Start for free
Sign up and claim your forever-free Fauna account
Request demo
Connect with a Fauna expert
Accelerating delivery with GraphQL and Fauna
Fauna instantly generates basic queries, mutations, and collections when you upload your GraphQL schema. This lets you start building your application immediately, without worrying about database setup and configuration. However, Fauna offers a lot more flexibility and power to GraphQL developers than simple create, read, update, and delete (CRUD) queries and mutations.
Today we’re announcing two new ways to simplify harnessing that power to deliver complete production applications to your users more quickly, auto-generated resolvers for user-defined functions (UDFs) and the Fauna workshop for GraphQL developers.
Auto-generated UDF resolvers
Fauna automatically generates queries and mutations for types you specify in your schema. You can modify this functionality by creating UDFs and connecting them to your queries and mutations with the
@resolver
directive. However, we heard from users that the process of creating and connecting UDFs could be simplified and that examples of arguments and return types for common CRUD operations would be valuable, especially for paginated queries.We listened, and now you can generate UDFs for CRUD operations on simple types by adding the
@generateUDFResolvers
directive to the type definitions in your schema! When you add this directive to a type Type, Fauna creates five new UDFs and connects each to the associated query or mutation:- create{Type} - Creates a new document in the Type collection with the information you specify.
- delete{Type} - Deletes a document in the Type collection with the specified ID.
- find{Type}ByID - Returns the information for a document in the Type collection with the specified ID.
- list{Type} - Returns a paginated list of all documents in the Type collection.
- update{Type} - Updates the information for a document in the Type collection with the specified ID.
You can then modify the behavior of your queries and mutations by changing the definition of these UDFs, for example, to restrict access based on user role or to implement “soft deletes.”
Auto-generated UDF resolvers are only available for simple types — types that do not have relations.
Fauna workshop for GraphQL developers
The Fauna workshop for GraphQL developers is a self-paced exploration of Fauna’s GraphQL features. The workshop does not assume any prior knowledge of Fauna or databases, and it guides you through building a full-stack serverless application using Next.js or SvelteKit in around two hours!
Currently, there are two sections, each of which should take around one hour to complete:
Even if you’ve used Fauna before, we recommend you complete both sections in order, as the first section includes some suggested practices that help you build and scale your application effectively.
Getting started with Fauna
The first section of the workshop explains how Fauna automatically generates resources for your application using your GraphQL schema. It introduces the Fauna dashboard and GraphQL playground, and teaches you how to accomplish common tasks such as authenticating users using GraphQL.
Building a full-stack serverless application
In the second section, you build a single-tenant serverless application using Next.js or SvelteKit! You learn how to connect to Fauna from your application using GraphQL. You implement user authentication and access control in your app. Finally, you retrieve and store data in your application using GraphQL and Fauna.
After completing both sections, you have the knowledge to start building your own full-stack serverless applications using Fauna and Next.js or SvelteKit — all in a couple of hours!
What’s next for GraphQL and Fauna
We’re currently adding a section to the workshop demonstrating how to build a multi-tenant software as a service (SaaS) application with Fauna and GraphQL. After that, we will add a section on CI/CD for Fauna and your application.
We also plan to deliver sections covering third-party integrations such as authorization with Auth0, search with Algolia, and payments with Stripe.
We hope these changes make it easier for you to bridge the simplicity of GraphQL and the power of Fauna. If you have feedback or want to see another integration in the workshop, let us know on our forums or in our Discord server!
If you enjoyed our blog, and want to work on systems and challenges related to globally distributed systems, serverless databases, and GraphQL, Fauna is hiring!
Subscribe to Fauna's newsletter
Get latest blog posts, development tips & tricks, and latest learning material delivered right to your inbox.