Coder Social home page Coder Social logo

e-commerce-service's Introduction

E-Commerce App powered with GraphQL ๐Ÿš€๐Ÿ‘ฉโ€๐Ÿ’ป

Table of Contents

Description

This is a backend graphql service that was developed to mimic part features of an E-commerce backend service.

Features in the service perform CRUD operations for:

  • Product
    • Name
    • Description
    • Quantity
    • Reviews, etc.
  • Category
    • Name
    • Products
  • Review
    • Title
    • Date
    • Comment
    • Rating, etc

The Build Process ๐Ÿ—๐Ÿ‘ฉโ€๐Ÿ”ฌ

The src folder contains the GraphQL schema, and resolvers for the various root queries available in the schema.

In the following lines below, a brief description will be given for each functionality.

Schema

The various schema definition will be explained below:

Product

type Product {
    id: ID!
    name: String!
    description: String!
    quantity: Int!
    ...
    category: Category
    reviews: [Review!]!
}

Category

type Category {
    id: ID!
    name: String!
    products(filter: ProductsFilterInput): [Product!]!
}

Review

type Review {
    id: ID!
    date: String!
    title: String!
    comment: String!
    rating: Int!
    productId: ID!
}

You can find the query and mutation schema definitions here

Resolvers

The resolvers folder, contains the resolver function handlers for the various schema definitions.

  • For the root-field category, categoryId is passed as an argument while sending the query. The categoryId is used to get the single category which the product belongs.
  • For the root-filed reviews, productId is retrieved from the parent params, so as get the particular product and return all the product reviews available.
  • The root-field products, returns all the products contained in a particular category. To get the products, a filtering functionality is applied to all the products to get the products with a particular categoryId. Also, the gotten products can be filtered based on - onSale boolean value - avgRating calculated value This gives the user the leverage of getting necessary data and not overloaded data.
  • The products root-field returns the all available products, and filters the products based on onSale and avgRating filter arguments provided (optionally), by the user
  • The product root-field returns a single product, based on the productId argument, used to find a single product if available
  • The categories root-field returns all the categories available.
  • et.c

Running the code

To run the code, make sure you are using node version >=14.17.0, npm version >=6.14.0

Follow the below steps, to run the code using your terminal

  • Cloning the project
$ git clone https://www.github.com/E-Zbox/e-commerce-app.git
  • Switch directories
$ cd e-commerce-app
  • Installing project dependencies
$ npm install
  • Starting the express server
$ npm run dev

or

$ npm start
  • Using Postman, navigate to localhost:<PORT>/graphql and run the various queries and mutation defined in the schema file

Cheers ๐Ÿฅ‚ you have successfully ran the code ๐ŸŽ‰๐Ÿพ.

Feel free to shop using the services provided ๐Ÿ˜‚๐Ÿ˜‚

Technologies used ๐Ÿ‘จโ€๐Ÿ’ปโš™

Developed using:

e-commerce-service's People

Contributors

e-zbox avatar

Stargazers

 avatar

Watchers

 avatar

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.