DEV Community

Cover image for Try FaunaDB's GraphQL API
Jessie Newell for Fauna, Inc.

Posted on • Updated on

Try FaunaDB's GraphQL API

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 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: https://graphql.fauna.com/graphql

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") {
    title
      todos {
      data {
        title
        completed
        _id
      }
    }
  }
}

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!

Top comments (4)

Collapse
 
dance2die profile image
Sung M. Kim • Edited

Hi Mahesh, I find FaunaDB interesting but,

We encourage the entire article to be published on DEV.to (if you have proper rights), with a linkback if appropriate. Otherwise, we recommend original material, such as an original commentary on the article.

From the Terms of Use:

Users must make a good-faith effort to share content that is...not designed primarily for the purposes of promotion or creating backlinks. Additionally, posts must contain substantial content — they may not merely reference an external link that contains the full post.

Posts that are simply intended to encourage readers to view an external resource are discouraged.

Thank you.

Collapse
 
maheshiyer75 profile image
Mahesh Iyer

Thank you for bringing this to our attention and regret the inconvenience caused due to this, I will update the entire article here shortly...

regards,
Mahesh

Collapse
 
maheshiyer75 profile image
Mahesh Iyer

The post has now been updated with the rest of the content.

Thread Thread
 
dance2die profile image
Sung M. Kim

Thank you Mahesh for the update :)