It turns out that lurking through internet can get you some idea or something for you to do to practice yourself. This is part of an assignment from MAQE. The nature of an assignment is not hard at all if you simply do it with RESTFUL
. Since we have been hearing about GraphQL
for years. This is a great oppurtunity to test the water.
I utilize the following lib for GraphQL
It turns out with this small project. You get to learn a thing or two.
-
GraphQL
is god at fetching data.RESTFUL
couldn't complete with this. -
I like
HttpStatus
code though,GraphQL
will return youSUCCESS
(200) no matter what. -
When fetching data, you use
POST
method for it. -
No Browser cache by default, can be done with in memory cache (Redis or MemcacaheD) DataLoader
-
You can setup
GraphQL
as middleman to call other services too with REST Data sources
The system supposes to return list of posts
along with its author in pagination manner. SO client can use that to render it.
With this being built with GraphQL
in mind, here is an endpoint on how to call it.
Here is the structure of query to use to get post
along with authors
query {
posts(postPagination: {
page: 1,
pageSize: 10,
}) {
id
title
description
imageUrl
createdAt
authors {
id
name
role
place
avatarUrl
}
}
}
Here is the collection to for all the endpoints for this projects. You can import via link right away with this.
-
CRUD for
authors
along with its pagination -
CRUD for
posts
along with its pagination
Remark since GraphQL recently supports by POSTMAN, you can only share the collection via link rather publishing doc to POSTMAN itself
Interesting references thanks to @indianajone and @SiwakornS