Skip to main content
  1. All Posts/

mini-ecommerce

eCommerce TypeScript

Demo Mini Ecommerce (Nextjs+GraphQL)

Install Project

install node mongodb
Goto Project Path

cd project_path

Install Package

npm install

or

yarn install

Init Environment

Add config file

cp .env.example .env

Change Config MONGO_URL

Seed Data AND Test Script

Seed

npm run seeds

or

yarn seeds

Test

npm run test

or

yarn test

Run Develop AND Build Script

Run Develop

npm run dev

or

yarn dev

Build And Run Production

npm run build
.
.
.
npm run start

or

yarn build
.
.
.
yarn start

Frontend Endpoint

localhost:3000

Backend Endpoint

localhost:3000/api/graphql

Demo Script

GET ALL PRODUCT

query($pagination: PaginationArg!) {
  products(pagination: $pagination) {
    items {
      id
      name
      price
      description
      image
      slug
    }
    count
  }
}

Query Value

{
  "pagination": { "offset": 0, "first": 10 }
}

CREATE ORDER

mutation createOrder($items: [OrderInputItem!], $amount: Float!, $vat: Float!) {
  createOrder(items: $items, amount: $amount, vat: $vat) {
    _id
  }
}

Query Value

{
  "items": [
    {
      "pid": "5f92b1628390263e9fd52ade",
      "name": "Awesome Granite Chair",
      "price": 54.0,
      "qty": 3
    }
  ],
  "amount": 162.0,
  "vat": 11.34
}