A simple GraphQL endpoint wrapping the AWESOME
JSONPlaceholder, a fake online REST API for testing and prototyping
This codebase and free tier Heroku deplyment offers the GraphiQL ui as a simple sandbox to try all of the specific GET queries offered by JSONPlaceholder. The "Good Stuff" is in the Schema.js file.
All Graphql queries are entered into the GraphiQL ui:
{
post(id:1){
userId
id
title
body
}
}
{
comment(id: 1) {
postId
id
name
email
body
}
}
{
album(id: 1) {
userId
id
title
}
}
{
photo(id: 1) {
albumId
id
title
url
thumbnailUrl
}
}
{
todo(id: 1) {
userId
id
title
completed
}
}
- Users https://jsonplaceholder.typicode.com/users/1
- (The UserType schema is truncated from the existing JSON Placeholder offerings.)
{
user(id: 1) {
id
username
email
phone
website
}
}
{
comments(postId: 1) {
postId
id
name
email
body
}
}
- (also experiment tunneling down into post and user, revealing the possibilities via a GraphQL Api...)
{
comments(postId: 1) {
postId
post {
title
user {
name
}
}
id
name
email
body
}
}
{
photos(albumId:1){
albumId
id
title
url
thumbnailUrl
}
}
{
albums(userId: 1) {
userId
id
title
}
}
{
todos(userId: 1) {
userId
id
title
completed
}
}
- (Experiment with completed criteria and accessing the User data as well, GraphQL good stuff)
{
todos(userId: 1,completed:true) {
user{
name
}
id
title
completed
}
}
{
posts(userId: 1) {
userId
id
title
body
}
}
This is intended to be an available Sandbox and learning tool, built off of the existing awesome learning tool, JSON Placeholder. Improvements would be to:
- Add front end to support an ad, to bump up the Heroku service level from the free tier
- Embed the GraphiQL ui in an iframe into the front end.
- Inject sample queries via frontend UI
- More Examples, along the lines of: https://www.howtographql.com/advanced/2-more-graphql-concepts/
- Implement the POST, PUT, PATCH, DELETE Restful API/ GraphQL mutations.
- Refactor the Schema into sub schemas