We’re overhauling Dgraph’s docs to make them clearer and more approachable. If
you notice any issues during this transition or have suggestions, please
let us know.
The App
This app is designed to manage lists of posts in different categories. A home page lets each user view a feed of posts, as follows:

- Dgraph Cloud provides the “backend”: a Dgraph database in a fully-managed environment
- Auth0 provides serverless authentication
- Netlify is used to deploy the app UI (the “frontend”)
Why use GraphQL?
You can build an app using any number of technologies, so why is GraphQL a good choice for this app? GraphQL is a good choice in many situations, but particularly where the app data is inherently a graph (a network of data nodes) and where GraphQL queries let us reduce the complexity of the UI code. In this case, both are true. The data for the app is itself a graph; it’s aboutusers
, posts
and comments
, and the links between them. You’ll naturally
want to explore that data graph as you work with the app, so GraphQL makes a
great choice. Also, in rendering the UI, GraphQL removes some complexity for
you.
If you built this app with REST APIs, for example, our clients (i.e., Web and
mobile) will have to programmatically manage getting all the data to render a
page. So, to render a post using a REST API, you will probably need to access
the /post/{id}
endpoint to get the post itself, then the
/comment?postid={id}
endpoint to get the comments, and then (iteratively for
each comment) access the /author/{id}
endpoint. You would have to collect the
data from those endpoints, discard extra data, and then build a data structure
to render the UI. This approach requires different code in each version of the
app, and increases the engineering effort required and the opportunity for bugs
to occur in our app.
With GraphQL, rendering a page is much simpler. You can run a single GraphQL
query that gets all of the data for a post (its comments and the authors of
those comments) and then simply lay out the page from the returned JSON. GraphQL
gives you a query language to explore the app’s data graph, instead of having to
write code to build the data structure that you need from a series of REST API
calls.