• Stars
    star
    1,026
  • Rank 43,321 (Top 0.9 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 6 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐ŸŒˆ Simple Fullstack GraphQL Application. API built with Express + GraphQL + Sequelize (supports MySQL, Postgres, Sqlite and MSSQL). WebApp built with React + Redux to access the API. Written in ES6 using Babel + Webpack.

fullstack-graphql

Fullstack GraphQL

Simple Demo Application

API built with Node + Express + GraphQL + Sequelize (supports MySQL, Postgres, Sqlite and MSSQL).

WebApp built with React + Redux.

Written in ES6 using Babel + Webpack.

๐Ÿ“ Features

  • List thoughts
  • Add thought
  • Delete thought
  • View single thought

โ–ถ๏ธ Running

  • Clone repo git clone [email protected]:atulmy/fullstack-graphql.git fullstack-graphql
  • Install NPM modules API cd api and npm install
  • Install NPM modules Webapp cd web and npm install
  • Modify /api/src/config/database.json for database credentials
  • Modify /api/src/config/config.json for API port (optional)
  • Modify /web/.env for web port (optional)
  • Run API cd api and npm start, browse GraphiQL at http://localhost:8000/
  • Run Webapp cd web and npm start, browse web at http://localhost:3000/

Sample API logs

[nodemon] starting `babel-node src/index.js --presets es2015,stage-2`
SETUP - Connecting database...
SETUP - Loading modules...
SETUP - GraphQL...
SETUP - Syncing database tables...
INFO - Database connected.
INFO - Database sync complete.
SETUP - Starting server...
INFO - Server started on port 3000.

๐Ÿ“ธ Screenshots

screenshot

Video: MOV

๐Ÿ— Core Structure

fullstack-graphql
  โ”œโ”€โ”€ api (api.example.com)
  โ”‚   โ”œโ”€โ”€ src
  โ”‚   โ”‚   โ”œโ”€โ”€ config
  โ”‚   โ”‚   โ”œโ”€โ”€ models
  โ”‚   โ”‚   โ”œโ”€โ”€ schema
  โ”‚   โ”‚   โ”œโ”€โ”€ setup
  โ”‚   โ”‚   โ””โ”€โ”€ index.js
  โ”‚   โ”‚
  โ”‚   โ””โ”€โ”€ package.json
  โ”‚
  โ”œโ”€โ”€ web (example.com)
  โ”‚   โ”œโ”€โ”€ public
  โ”‚   โ”œโ”€โ”€ src
  โ”‚   โ”‚   โ”œโ”€โ”€ components
  โ”‚   โ”‚   โ”œโ”€โ”€ setup
  โ”‚   โ”‚   โ””โ”€โ”€ index.js
  โ”‚   โ”‚
  โ”‚   โ”œโ”€โ”€ .env
  โ”‚   โ””โ”€โ”€ package.json
  โ”‚
  โ”œโ”€โ”€ .gitignore
  โ””โ”€โ”€ README.md

๐Ÿ“˜ Guides

API

  • Adding new Module (Eg: Users):
    • Copy /api/src/models/thought.js to /api/src/models/user.js and modify the file for table name and respective fields
    • Add an entry to the models object in /api/src/models/index.js
    • Copy /api/src/schema/thoughts to /api/src/schema/users and modify type.js, resolvers.js and fields/query.js and fields/mutations.js
    • Import /api/src/schema/users/fields/query.js in /api/src/schema/query.js
    • Import /api/src/schema/users/fields/mutations.js in /api/src/schema/mutations.js

Webapp

  • Adding new Module (Eg: Users):
    • Create folder users under /web/src/components/
    • Create your Container and Resusable components under /web/src/components/users
    • Create api folder under /web/src/components/users
    • Add actions.js where all your Redux Action Types and Actions will reside (refer /web/src/components/thoughts/api/actions.js)
    • Add state.js where all your respective Reducers will recide (refer /web/src/components/thoughts/api/state.js)
    • Import the module state in /web/src/setup/store.js to make it avaliable to the app
    • Encapsulate all your User related code in /web/src/components/users
  • Adding new Route (Eg: /users):
    • Add a new entry to routes object in /web/src/setup/routes.js (eg user: { list: '/list' })
    • Edit /web/src/components/App.js and add the route entry

Sample GraphQL Queries

These queries are generated on client side using queryBuilder() helper defined in /web/src/setup/helpers.js

Query - Get List

query {
  thoughts {
    id,
    name,
    thought
  }
}
                

Response

{
  "data": {
    "thoughts": [
      {
        "id": 1,
        "name": "Arya Stark",
        "thought": "A girl has no name"
      },
      {
        "id": 2,
        "name": "Jon Snow",
        "thought": "I know nothing"
      }
    ]
  }
}
                

Query - Get by Param

query {
  thought(id: 1) {
    id,
    name,
    thought
  }
}
                

Response

{
  "data": {
    "thought": {
      "id": 1,
      "name": "Arya",
      "thought": "A girl has no name"
    }
  }
}
                

Mutation - Create

mutation {
  thoughtCreate(
    name: "Tyrion Lannister", 
    thought:"I drink and I know things"
  ) {
    id
  }
}
                

Response

{
  "data": {
    "thoughtCreate": {
      "id": 3
    }
  }
}
                

Mutation - Remove

mutation {
  thoughtRemove(id: 3) {
    id
  }
}
                

Response

{
  "data": {
    "thoughtRemove": {
      "id": null
    }
  }
}
                

๐Ÿ’ฌ Community Reviews

Facebook Groups: NodeJS โ€ข ReactJS โ€ข GraphQL

Reddit: NodeJS โ€ข ReactJS โ€ข GraphQL

โญ Showcase

Following projects have been built with or inspired from fullstack-graphql

  • Crate - Get monthly subscription of trendy clothes and accessories - GitHub
  • HIRESMART - Application to streamline hiring process - GitHub
  • Would really appreciate if you add your project to this list by sending a PR

Resources

๐ŸŽฉ Authors

๐Ÿ‘ Donate

If you liked this project, please donate to support it โค๏ธ

Donate via PayPal

๐Ÿ“œ License

Copyright (c) 2017-18 Atul Yadav http://github.com/atulmy

The MIT License (http://www.opensource.org/licenses/mit-license.php)

More Repositories

1

crate

๐Ÿ‘• ๐Ÿ‘– ๐Ÿ“ฆ A sample web and mobile application built with Node, Express, React, React Native, Redux and GraphQL. Very basic replica of stitchfix.com / krate.in (allows users to get monthly subscription of trendy clothes and accessories).
JavaScript
2,400
star
2

fullstack-javascript-architecture

โœ๏ธ Opinionated project architecture for Full-Stack JavaScript Applications.
JavaScript
652
star
3

oauth

๐Ÿ”— OAuth 2.0 implementation for various providers in one place.
JavaScript
426
star
4

gql-query-builder

๐Ÿ”ง Simple GraphQL Query Builder
TypeScript
354
star
5

node-express-react-redux-zwitter

๐Ÿฃ A basic clone of Twitter (Boilerplate App) - Separate API (express+mongo) and Frontend (react+redux) folders using Node, Express, MongoDB, React (create-react-app), React Router v4 and Redux.
JavaScript
92
star
6

universal-react

๐ŸŒ A simple universal react application with server side rendering built with latest versions of React (v16+), React Router (v5+), Redux (v4+), Express (v5+), Webpack (v4+), Babel Preset ES6 ๐Ÿ‘จโ€๐Ÿ’ป
JavaScript
79
star
7

hire-smart

โœ… HIRE SMART (community edition) - Streamline hiring process, scheduling interviews and tracking candidates.
JavaScript
70
star
8

react-recoil

A sample implementation of React Recoil.
JavaScript
44
star
9

react-native-curated

๐Ÿ’โ€โ™‚๏ธ Hand picked collection of packages, tutorials and more for React Native.
43
star
10

wispy

๐ŸŒฑ An experimental lightweight (remote procedure call) API pattern.
JavaScript
36
star
11

meteor-react-simple-chat

๐Ÿ’ฌ Basic chat application using Meteor 1.4 and React.
JavaScript
25
star
12

meteor-baseui

๐Ÿ“ฑ๐Ÿ–ฅ Basic UI: Mobile + Web
HTML
13
star
13

node-react-zwitter

๐Ÿง NodeJS, Express, MySQL and React Boilerplate App - Zwitter (Basic clone of Twitter)
JavaScript
13
star
14

cv

๐Ÿ“„ Curriculum Vitae
12
star
15

meteor-bootstrap

๐Ÿฃ Meteor Bootstrap / Boilerplate Project with essential folder structures and packages.
JavaScript
10
star
16

meteor-mafia

๐ŸŽฎ Mafia: The Party Game!
JavaScript
9
star
17

meteor-rock-paper-scissors

๐Ÿ‘Šโœ‹โœŒ๏ธ Rock Paper Scissors - Play online with your friends or with computer
JavaScript
7
star
18

meteor-tictactoe

๐ŸŽฎ Tic Tac Toe - Play multiplayer online with your friends
JavaScript
6
star
19

node-express-handlebars-zwitter

๐Ÿง NodeJS, Express, Mongoose and Handlebars Boilerplate App - Zwitter (Basic clone of Twitter)
JavaScript
5
star
20

jquery-connectors

๐Ÿ”— Draws a path between two HTML elements.
JavaScript
5
star
21

fullstack-validator

๐Ÿ›ก A simple validation library for server and client side JavaScript applications.
TypeScript
5
star
22

meteor-1.4-zwitter

๐Ÿง Meteor 1.4 Boilerplate App - Zwitter (Basic clone of Twitter)
JavaScript
4
star
23

tool-aspectratio

๐Ÿ“ฑ ๐Ÿ–ฅ ๐Ÿ’ป Calculate aspect ratio online for images, display screens, montors and mobile easily.
PHP
4
star
24

node-basics

Basics of NodeJS
JavaScript
4
star
25

php-angular-easyapp

An easy, flexible, very light weight, extendable, small to medium scale application template. Recommended for beginners exploring web technologies. Best suited for SPAs and RIAs.
PHP
4
star
26

meteor-react-zwitter

๐Ÿง Meteor + ReactJS Boilerplate App - Zwitter (Basic clone of Twitter)
JavaScript
3
star
27

baseui

๐Ÿ“ฑ๐Ÿ–ฅ Basic UI: Mobile + Web
HTML
3
star
28

node-express-angular-job-finder

๐Ÿ” A sample app built on Mongo, Express and Angular and Node
CSS
2
star
29

workstation

1
star