This repository is a sample implementation of reponse from JSONPLACEHOLDER.TYPICODE, a free to use rest API site for sample project development.
- NodeJS v8.10.0
- npm 5.7.0
- nodemon
- GraphQL-yoga - For GraphQL implementation
- Node-Fetch - for performing REST Calls
- Clone the repo.
- Go into the folder and run
npm install
or
yarn
if you have yarn package manager.
Now to run server use the following command:
nodemon app.js
This will run the project in port 4000. Visit http://localhost:4000, You will see something like this.
This makes quering GraphQL queries very easy and can do reload relatively faster than using graphiql.
Eg: Peform the following to get the result as follows:
- Getting post with id = 1
{
getPosts(id: 1) {
id
title
body
}
}
- Getting user info as well
{
getPosts(id: 1) {
id
title
body
userId {
id
name
username
email
phone
website
}
}
}
- finally get user and all the posts
{
getUser(userId: 1) {
id
name
username
email
phone
website
posts{
id
title
body
}
}
}
More GraphQL Coming soon ....