Screen Shot 2019 06 07 at 3 47 32 PM

Try FaunaDB's GraphQL API


The Fauna Cloud Console now has GraphQL Playground!

This blog was written before we added GraphQL Playground to our Cloud Console. Although this tutorial will still work, we recommend that you follow this tutorial series instead:

  1. Getting started with GraphQL
  2. GraphQL Relations
  3. Unique Constraints in GraphQL
  4. GraphQL Pagination

GraphQL is quickly becoming the default language for working with APIs and data, making it easy to stitch sources together, and enabling API consumers to move fast without breaking things. Fauna is proud to announce our native GraphQL API, available today in FaunaDB Cloud! Instructions to try it are just after the screenshot in this post.

Now you can talk to the database in GraphQL. This means developers who want a backend data API for their app can get started just by importing a basic GraphQL schema, and FaunaDB will take care of creating the underling collections, indexes, and relationships. Advanced applications can use FaunaDB’s transaction-oriented FQL to extend GraphQL schemas.

FaunaDB’s cloud database is fully-managed and free to get started with, so it’s effortless to add a GraphQL backend to your app. FaunaDB’s strongly consistent ACID transactions mean you don’t have to guess what’s in the database, cutting down on edge cases, and making it a great fit for everything from user profiles to game worlds to financial services workloads.

Instantly query FaunaDB from any GraphQL client

The easiest way to get a taste of GraphQL on FaunaDB is to launch GraphQL Playground and query the sample database we’ve prepared for you.

To try it out, just configure GraphQL playground to connect to the FaunaDB Cloud GraphQL API endpoint:

Authorize your client to the sample database by pasting the following into the HTTP Headers in the lower left corner:

{ "Authorization": "Basic Zm5BRFFVdWNRb0FDQ1VpZDAxeXVIdWt2SnptaVY4STI4a2R6Y0p2UDo=" }

Now that you are connected, paste this into the query box and run it:

query FindAListByID {
  findListByID(id: "234550211483009539") {
    todos {
      data { 

You should see a handful of todo items pop up in the results area, like in the screenshot above. Under the hood the GraphQL engine is making use of FaunaDB joins to connect todos and lists, and as a user you don’t have to think about it.

You can inspect the schema by clicking the tab on the right hand side. This blog post includes a read-only authorization key, so don’t worry, you can’t break anything.

If you want to get serious, you’ll need your own database. Part 1 in our Getting Started with GraphQL series shows you how to set up a database and import your GraphQL schema. Once you have signed up for a FaunaDB Cloud account, you'll be able to access GraphQL Playground directly within FaunaDB's cloud console. Enjoy!