Skip to content

spike04/Graphql_Sample_jsonplaceholder.typicode.com

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Graphql - jsonplaceholder.typicode.com


This repository is a sample implementation of reponse from JSONPLACEHOLDER.TYPICODE, a free to use rest API site for sample project development.

Requirements: (Developed in)

  1. NodeJS v8.10.0
  2. npm 5.7.0
  3. nodemon

Modules Used:

  1. GraphQL-yoga - For GraphQL implementation
  2. Node-Fetch - for performing REST Calls

How to run the project

  • 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.

Yoga Playground

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
  }
}

Get Post Graphql

  • Getting user info as well
{
  getPosts(id: 1) {
    id
    title
    body
    userId {
      id
      name
      username
      email
      phone
      website
    }
  }
}

Get Post and User

  • finally get user and all the posts
{
  getUser(userId: 1) {
    id
    name
    username
    email
    phone
    website
    posts{
      id
      title
      body
    }
  }
}

Get user info and Post associated with that user

More GraphQL Coming soon ....

About

A sample Graphql Application to fetch data from http://jsonplaceholder.typicode.com and display the result

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published