CRUD App with Next.js, FaunaDB and GraphQL
How to perform CRUD operations using GraphQL in a Next.js and FaunaDB app.
In my last article, I wrote about how to use FQL in FaunaDB to perform CRUD operations. This time, I’ll write about how to use GraphQL instead to perform CRUD operations.
Fauna provides the FaunaDB GraphQL API, a database service for defining schemas and querying and mutating data within FaunaDB. Also, GraphQL Playground is embedded into FaunaDB Console. It’s nice for developers.
In this tutorial, we’ll build a simple application with Next.js and try creating, retrieving, updating and deleting (CRUD) documents using GraphQL in FaunaDB.
What we will:
- Create a Next.js app
- Create a GraphQL schema
- Sign up for a FaunaDB account
- Create a GraphQL database
- Retrieve documents
- Create a document
- Update a document
- Delete a document
Please note that this article is likely to be lengthy, so I will omit detailed explanations. For the same reason I will also omit all styles in the source code, but they are on GitHub.