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 backend.
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 will be working with in this article) is a data manipulation and query language that gives you the power of 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 Users, Posts, and Comments (user has many posts, post has many comments, user has many comments) 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.
You can find all the example code for this article here.
#graphql #graph-database #apollo