In this article, I’m going to explore graph databases/GraphQL by building a proof-of-concept blog powered by the recently launched Slash GraphQL — a hosted-GraphQL back end.
Graphs are a fascinating way to model the information in a system where the relationships (edges) between pieces of data (nodes) are first-class entities of the system. This is a different approach to the more common relational database (RDBMS) model, where the relationships between records are implied. For example, “this user owns this post because user.id == post.user_id
.”
Graphs are most useful when the relationships among the data are as important as the data itself. For instance:
In general, graphs offer more descriptive queries, greater flexibility in adapting your model, and better performance when traversing relationships. GraphQL (which we’ll be working with in this article) is a data-manipulation and query language that gives you the power to graph through an API.
Working with graphs can feel a little unfamiliar if you’re used to working with RDBMSs, so in this article, I’ll try to show you some of the basics. I’m going to build a GraphQL-powered blog. The relationships between User
s, Post
s, and Comment
s (User
has many Post
s, Post
has many Comment
s, User
has many Comment
s) highlight the power of GraphQL, as you’ll see below. As usual, I’m not trying to produce finished, production-ready code here — just simple examples to show you the underlying concepts.
#apollo #javascript #graphql #database