GithubHelp home page GithubHelp logo

nodejs-express-graphql's Introduction

Node.js + Express.js + Apollo Server Express + GraphQL + TypeScript + TypeORM + WebPack + PostgreSQL

  1. clone repo

  2. create postgres database (you can find db setting in .env)

it should contain a 'Contact' table for start

CREATE TABLE template."Contact"
(
    id integer NOT NULL DEFAULT nextval('template."Contact_id_seq"'::regclass),
    "firstName" character varying(255) COLLATE pg_catalog."default" NOT NULL,
    "lastName" character varying(255) COLLATE pg_catalog."default" NOT NULL,
    email character varying(255) COLLATE pg_catalog."default" NOT NULL,
    phone character varying(13) COLLATE pg_catalog."default",
    "createdDate" timestamp without time zone NOT NULL DEFAULT now(),
    "lastModifiedDate" timestamp without time zone NOT NULL DEFAULT now(),
    CONSTRAINT "Contact_pkey" PRIMARY KEY (id)
)
  1. make changes on .env and ormconfig.json files (db settings etc)

  2. run the following commands for install application deps: yarn install

  3. build application yarn build:dev - development mode

yarn build:prod - production mode

  1. start application yarn start

finally, GraphQL server will be available by address: http://localhost:3000/api

graphql query example:

query {
  contacts(filter: {
    page: 1
    perPage: 10
  })
  {
    totalCount
    contacts {
      id
      firstName
      lastName
      email
      phone
      createdDate
      lastModifiedDate
    }
  }
}
query {
  contact(id: 1)
  {
      id
      firstName
      lastName
      email
      phone
      createdDate
      lastModifiedDate
  }
}

graphql mutation example:

mutation {
  contactCreate(input: {
    firstName: "first name 3"
    lastName: "last name 3"
    email: "email3@email3"
    phone: "123 123 123"
  })
  {
    id
    firstName
    lastName
    email
    phone
    createdDate
    lastModifiedDate
  }
}

nodejs-express-graphql's People

Watchers

Joshua 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.