Fetch Single Post

How to fetch a blog post by slug

unclebigbay avatar
Written by unclebigbay
Updated over a week ago

In this guide, we'll discuss how to fetch a single publication post using its slug and cuid in the post query.

Because blogs on Hashnode can have the same post title or slug, we use the slug and cuid of an article to find the correct article.

Learn how to get the slugs and cuid of your publication posts from this guide.

You can get the following data from the publication post query:

_id: ID!

followersCount: Int

author: User

cuid: String

slug: String

title: String

type: String!

popularity: Float

reactionsByCurrentUser: [Reaction]

totalReactions: Int

bookmarkedIn: [String]

partOfPublication: Boolean

contributors: [Contributor]

isActive: Boolean

replyCount: Int

responseCount: Int

dateAdded: String

tags: [Tag]

brief: String

coverImage: String!

isAnonymous: Boolean

dateUpdated: String

dateFeatured: String

reactions: [Reaction]

poll: Poll

contentMarkdown: String

numUniqueUsersWhoReacted: Int

Concatenate the slug and the cuid of the post as slug-cuid and pass it as an argument to the post query as follows:

post(slug: "data-types-in-javascript-cl9ppazy6000609kz95r3gs0p", hostname: "") {
author {

Note: The hostname parameter is required and can be set as an empty string.

The query above will return the details of the post as follows:

Next Articles:

Did this answer your question?