CYCBrian / 21-Book-Search-Engine-RestfulAPI-to-Graphql-Refactoring

Taking a fully functioning Google Books API search engine built with a RESTful API, and refactor it to be a GraphQL API built with Apollo Server. The app was built using the MERN stack, with a React front end, MongoDB database, and Node.js/Express.js server and API.
MIT License
0 stars 0 forks source link

back-end: typeDefs.js #4

Open CYCBrian opened 6 months ago

CYCBrian commented 6 months ago

define the necessary Query and Mutation Types

CYCBrian commented 6 months ago
* `Query` type:

  * `me`: Which returns a `User` type.

* `Mutation` type:

  * `login`: Accepts an email and password as parameters; returns an `Auth` type.

  * `addUser`: Accepts a username, email, and password as parameters; returns an `Auth` type.

  * `saveBook`: Accepts a book author's array, description, title, bookId, image, and link as parameters; returns a `User` type. (Look into creating what's known as an `input` type to handle all of these parameters!)

  * `removeBook`: Accepts a book's `bookId` as a parameter; returns a `User` type.

* `User` type:

  * `_id`

  * `username`

  * `email`

  * `bookCount`

  * `savedBooks` (This will be an array of the `Book` type.)

* `Book` type:

  * `bookId` (Not the `_id`, but the book's `id` value returned from Google's Book API.)

  * `authors` (An array of strings, as there may be more than one author.)

  * `description`

  * `title`

  * `image`

  * `link`

* `Auth` type:

  * `token`

  * `user` (References the `User` type.)
CYCBrian commented 6 months ago

I think I did it correctly.