Skip to content

Dad joke "dadabase" built with json-server and GraphQL

Notifications You must be signed in to change notification settings

thawkin3/dad-joke-dadabase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dad Joke "Dadabase"

Groan at some dad jokes and rate them as well. Which joke will be your favorite?

This app is built with Apollo. The original REST API is built with JSON Server and can be found here: https://github.com/thawkin3/dad-joke-dadabase-rest-api

Running the app locally

  1. npm install
  2. npm start

This will start the app on port 4000. The GraphQL API endpoint is at /graphql.

REST API with json-server

Database

# See the current database contents
GET /db

Jokes

GET    /jokes
GET    /jokes/1
POST   /jokes
PUT    /jokes/1
PATCH  /jokes/1
DELETE /jokes/1

# Get a specific joke with all ratings included
GET /jokes/1?_embed=ratings

# Get all ratings for a specific joke
GET /jokes/1/ratings

# Get all jokes with all ratings included
GET /jokes?_embed=ratings

Ratings

GET    /ratings
GET    /ratings/1
POST   /ratings
PUT    /ratings/1
PATCH  /ratings/1
DELETE /ratings/1

# Get all ratings for a specific joke
GET /ratings?jokeId=1

# Get a rating along with the joke itself
GET /ratings/1?_expand=joke

GraphQL API with Apollo Server

Jokes

Get all jokes

query GetAllJokes {
  jokes {
    id
    content
  }
}

Get all jokes with ratings

query GetAllJokesWithRatings {
  jokes {
    id
    content
    ratings {
      score
    }
  }
}

Get a specific joke

query GetJoke {
  joke(id: 1) {
    id
    content
  }
}

Get a specific joke with ratings

query GetJokeWithRatings {
  joke(id: 1) {
    id
    content
    ratings {
      score
    }
  }
}

Ratings

Get all ratings

query GetAllRatings {
  ratings {
    id
    jokeId
    score
  }
}

Create a new rating

mutation CreateRating {
  rating(jokeId: 1, score: 8) {
    id
    score
    jokeId
  }
}

Resources

About

Dad joke "dadabase" built with json-server and GraphQL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published