Skip to content

Latest commit

 

History

History
32 lines (21 loc) · 904 Bytes

File metadata and controls

32 lines (21 loc) · 904 Bytes

GraphQL Basic Example using JSONPlaceholder test API with express-graphql and node-fetch modules

Quick starter repo example that uses the http://jsonplaceholder.typicode.com/ JSON test API.

Converts the jsonplaceholder endpoint into a GraphQL compatible query which then allows you to use GraphQL to lookup a post via the posts id as argument

Clone repo and, install packages, start the server.

$ npm install
$ node ./app.js

Open browser: http://localhost:4000/graphql to load the GraphiQL query web interface tool

Run a test query (specify the post id for example: 98) and specifiy the types of data you want to return. You can specify for example (userId, id, title, body)

query{
  posts(id:98){
    userId,
    id,
    title,
    body
  }
}

yo