Build a Message Board App in React with Dgraph Learn. Step 2: GraphQL schema design - how graph schemas and graph queries work.
user
, their posts
, and the comments
on
those posts, or the network of friends of a user, or the kinds of posts a user
tends to like.
user
is going to have some number of posts
and a post
can have exactly
one author
. A post
can be in only a single category
, which, in turn, can
contain many posts
.
How does that translate into the app data graph? Let’s sketch out some examples.
Let’s start with a single user who’s posted three posts into a couple of
different categories. Your graph might start looking like this.
/post/0x2
, then you’ll follow edges to the post’s
author and category, but you’ll also need to follow the edges to all the
comments, and from there to the authors of the comments. That’ll be a multi-step
traversal like the following sketch.