Skip to content

rachelrly/graphql-bookshelf-api

Repository files navigation

This API delivers data about books from JSON files with an Express/GraphQL server.

View the repository for the React client with Apollo here.

View the live app here.

Tech

  • Node.js
  • Express.js
  • GraphQL
  • Deployed with Heroku

Images

Books can be filtered by author, genre, or rating.

When viewing a book, users can see other books by the author. If an author has no other books, books of the same genre are displayed.

Example Query

This query returns the name of the genre with id 1 and all books of the given genre, along with their id, title, and the author's first and last name.

{
genre(id:1){
    id,
    name,
    books{
        id,
        title,
        author{
            firstName,
            lastName
        }
    }
}
}

Schema

BookType

  • id
  • title
  • genre (id points to GenreType)
  • published
  • rating
  • author (id points to AuthorType)

AuthorType

  • id
  • firstName
  • lastName

GenreType

  • id
  • name

Making Queries

The GraphQL Bookshelf API only has one endpoint: /graphql.

From this endpoint, users can query for books, genres, and authors. BookType has foreign keys to GenreType and AuthorType. Users can access lists of books from a specified genre or author through the graph.

All lists of books are filtered by rating, with the highest rated books at the top of the list.

BookType

books

Returns a list of books.

books(exclude: 1)

Returns every book except book 1.

The excludes argument can be used in cojunction with genre or rating arguments.

This is used to exclude the current book in a list of books also by this author

book(id: 1)

Queries for single book by id.

books(rating: 4)

Queries for all books with a rating of 4 or higher.

AuthorType

authors

Returns a list of authors.

author(id: 1)

Returns author with id of 1.

Can get a list of books by the author with specified id.

GenreType

genres

Returns a list of genres.

genre(id: 1)

Returns genre with id of 1.

Can get a list of books from genre of specified id.

About

GraphQL API that uses the JavaScript implementation to deliver data about some of my favorite books. This data is filterable by author, genre, and my rating.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published