Giter Club home page Giter Club logo

react-app-simple-book-search-graphql's Introduction

react-app-simple-book-search-graphql

A Simple Book Search Application using React JS, a JavaScript library to make awesome UI by Facebook, Node JS with AWS Lambda and MongoDB. To connect with the Backend GraphQL Server Apollo Client is used while Apollo Server is used to implement the Server.

This application uses component oriented UI creation paradigm. All components are written in JSX and ES6 style and are combined to get a single build for production purpose using Webpack 5.

Babel is used to transpile all JSX code to vanilla JavaScript. For UI creation HTML5 and CSS3 are used.

This is a responsive web application for viewing in both Mobile and Desktop.

Back end is implemented using Node JS with Apollo Server and MongoDB Atlas.

This Application uses standalone GraphQL Server. For Backend Deployment with AWS Lambda details please check aws-lambda branch.

Features

  1. Code is rewritten with latest version of React JS and Node JS.
  2. Latest features of JavaScript i.e. ESNext is used.

  1. This is Simple Book Search Application. It is a CRUD application.
  2. It is a Full Stack Application with Standalone GraphQL Server. For the Backend with AWS Lambda please check the aws-lambda branch.
  1. All the book details, authors and publication detils are stored in the MongoDB Atlas. This example uses a free/ shared account. So Please use it wisely.
  1. Login feature is added.
  2. Error will be shown if the credentials are not correct or Network is not present.
  3. Session tracking is supported using JSON Web Tokens (JWT). These tokens are saved into LocalStorage.
  4. To implement the features of GraphQL like Queries, Mutations in Client side Apollo Client is used. On the otherhand, Apollo Server is used to implement the same in Server side.
  1. for simplicity passwords are not encrypted
  1. For the Schema generation Type Definitions are added. Queries are used for the Reading operations while Mutations are added for Mutable operations.

Installation

Clone the repository:

$ git clone https://github.com/anijitsao/react-app-simple-book-search-graphql.git

Navigate inside the directory:

$ cd react-app-simple-book-search-graphql

Install all the necessary dependecies and run the client side of the application

$ npm install

# To serve the application we use a npm module named http-server
$ npm run client-start

Now open Another Terminal and navigate to the same directory and run the GraphQL Server

$ cd /path/to/react-app-simple-book-search-graphql

# Run the GraphQL Server
$ npm run server-start

Login to book search


  1. Open web browser and typehttp://localhost:8080 in the address bar to load the application.
  2. Now login with Test users.

Test users

Username Password
admin admin123

tested with latest versions of Google Chrome and Mozilla Firefox

However, to test GraphQL API you can use any supported Client like Apollo Sandbox with the url and HTTP Verbs as shown in Terminal.

API Listing

API listing is given below, -

All APIs have common endpoint as following.

POST /url-of-the-deployed-service/graphql (for localhost it will be http://localhost:4000/graphql)

Following Queries use the same URL mentioned above

query CreateTokenQuery{
  // these are the only possible username and password
  createToken(username: "admin", password: "admin123") {
    token
  }
}
query HelloQuery {
  hello
}
query FindBooksQuery {
  findBooks {
    _id
    name
    published
  }
}
query FindAllAuthors{
  findAuthors {
    _id
    firstName
    lastName
  }
}

Following Mutations have the same URL mentioned above

mutation ModifyCount {
  getCount(count: 20)
}
mutation AddBookMutation {
  addBook(name: "You Don't Know JS") {
    _id
    name
  }
}
mutation DeleteBookMutation {
  deleteBook(_id: "id-of-the-book-to-delete")
}
mutation UpdateBookMutation($updateId: ID!, $bookData: UpdataBookParams!) {
  updateBook(_id: $updateId, updateBookData: $bookData)
}

// variables
{
  "updateId": "id-of-the-book-to-update",
  "bookData": {
   "name": "You Don't Know ES6"
  }
}

Following Author related Mutations have the same URL mentioned above

mutation AddAuthorMutation {
  addAuthor(firstName: "Agatha", lastName: "Christie"){
    _id
    firstName
  }
}
mutation DeleteAuthorMutation {
  deleteAuthor(_id: "id-of-the-author-to-delete")
}
mutation UpdateAuthorMutation(
  $updateId: ID!
  $authorData: UpdataAuthorParams!
) {
  updateAuthor(_id: $updateId, updateAuthorData: $authorData)
}

// variables
{
  "updateId": "id-of-the-author-to-update",
  "authorData": {
   "firstName": "Agatha",
   "lastName": "Christie",
   "country": "United Kingdom"
  }
}

Screenshots

Some screens of the application is given below for better understanding.

Desktop as well as Mobile version of the screenshots are given side by side.

Login Screen

If credentials are not correct

After submitting credentials and Search a book

Add a Book

Edit a Book

Delete a Book

react-app-simple-book-search-graphql's People

Contributors

anijitsao avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

weisisheng

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.