Member-only story

Build a simple blogging api service using GraphQL

Michael Tong
10 min readAug 30, 2024

--

Photo by Arnel Hasanovic on Unsplash

Today we will be building a blogging service that consists of 4 components: users, tags, posts, and comments. Let’s talk about their relationship first.

  • Users: this one is pretty obvious. We are talking about a person that can come in to the service and create different posts. A user can also go to different posts and make multiple comments.
  • Posts: These are posts that users comment on. Each post is created by one user. It can contain multiple comments, created by the post’s user or other users. It can only contain multiple tags.
  • Comments: This is a message posted by different users on posts. Each posts can have multiple comments, with each comment created by different/same user.
  • Tags: This refers to the categorization of different posts. For example, a tag can be “science” or “food”, which is the topic the post is on. A post can also have multiple tags. For example, there can be a post that talks about a science museum, being tagged “science” and “culture” at the same time. Likewise, each tag can contain multiple posts, such as have different blogging posts that is related to science.

Next, let’s go ahead and build the service using graphql and node:

const express = require('express');
const { graphqlHTTP } =…

--

--

Michael Tong
Michael Tong

Written by Michael Tong

Just a dad spending tons of time building backend services and frontend projects for fun :D

No responses yet