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
npm install
npm start
This will start the app on port 4000. The GraphQL API endpoint is at /graphql
.
# See the current database contents
GET /db
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
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
query GetAllJokes {
jokes {
id
content
}
}
query GetAllJokesWithRatings {
jokes {
id
content
ratings {
score
}
}
}
query GetJoke {
joke(id: 1) {
id
content
}
}
query GetJokeWithRatings {
joke(id: 1) {
id
content
ratings {
score
}
}
}
query GetAllRatings {
ratings {
id
jokeId
score
}
}
mutation CreateRating {
rating(jokeId: 1, score: 8) {
id
score
jokeId
}
}
- json-server: https://github.com/typicode/json-server
- Apollo GraphQL full-stack tutorial: - https://www.apollographql.com/docs/tutorial/introduction/
- Apollo GraphQL full-stack tutorial GitHub repo: https://github.com/apollographql/fullstack-tutorial
- Defining a GraphQL schema: https://www.apollographql.com/docs/apollo-server/schema/schema/
- Layering GraphQL on top of an existing REST API: https://www.apollographql.com/blog/layering-graphql-on-top-of-rest-569c915083ad/
- Apollo server data sources: https://www.apollographql.com/docs/apollo-server/data/data-sources/
- Apollo server middleware: https://www.apollographql.com/docs/apollo-server/integrations/middleware/
- apollo-server-express: https://www.npmjs.com/package/apollo-server-express
- Apollo client: https://www.apollographql.com/docs/react/get-started/
- Calling a GraphQL API with Fetch: https://www.apollographql.com/blog/4-simple-ways-to-call-a-graphql-api-a6807bcdb355/
- Mutation resolvers: https://www.apollographql.com/docs/tutorial/mutation-resolvers/