fullstack-graphql-angular
                                
                                 fullstack-graphql-angular copied to clipboard
                                
                                    fullstack-graphql-angular copied to clipboard
                            
                            
                            
                        Simple Fullstack GraphQL Application with Angular CLI + Redux. API built with Typescript + Express + GraphQL + Sequelize (supports MySQL, Postgres, Sqlite and MSSQL). WebApp built with Angular CLI + R...

Fullstack GraphQL Angular
Created from fullstack graphql, implement additional support for Typescript, Angular CLI and ngrx.
Simple Demo Application
API built with Node + Express + GraphQL + Sequelize (supports MySQL, Postgres, Sqlite and MSSQL).
WebApp built with Angular CLI + Redux + Async Middleware.
Written in Typescript using Babel + Angular CLI.
π Features
- [x] List thoughts
- [x] Add thought
- [x] Delete thought
- [x] View single thought
βΆοΈ Running
- Clone repo git clone [email protected]:rafaesc/fullstack-graphql-angular.git fullstack-graphql-angular
- Install NPM modules API cd apiandnpm install
- Install NPM modules Webapp cd webappandnpm install
- Modify /api/src/config/database.jsonfor database credentials
- Modify /api/src/config/config.jsonfor API port (optional)
- Modify /webapp/.envfor webapp port (optional)
- Run API cd api,npm run buildandnpm start, browse GraphQL at http://localhost:3000/
- Run Webapp cd webappandnpm start, browse webapp at http://localhost:4200/
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

π Core Structure
fullstack-graphql-angular
  βββ api (api.example.com)
  β   βββ src
  β   β   βββ config
  β   β   βββ models
  β   β   βββ schema
  β   β   βββ setup
  β   β   βββ index.js
  β   β
  β   βββ package.json
  β
  βββ webapp (example.com)
  β   βββ public
  β   βββ src
  β   β   βββ app
  β   β       βββ@core
  β   β       βββ@shared
  β   β       βββpages
  β   β       βββapp.module.ts
  β   β
  β   βββ package.json
  β
  βββ .gitignore
  βββ README.md
π Guides
API
- Adding new Module (Eg: Users):
- Copy /api/src/models/thought.tsto/api/src/models/user.tsand modify the file for table name and respective fields
- Add an entry to the modelsobject in/api/src/models/index.ts
- Copy /api/src/schema/thoughtsto/api/src/schema/usersand modifytype.ts,resolvers.tsandfields/query.tsandfields/mutations.ts
- Import /api/src/schema/users/fields/query.tsin/api/src/schema/query.tsand add user to the fields
- Import /api/src/schema/users/fields/mutations.tsin/api/src/schema/mutations.tsand add user to the fields
- To activate these changes do cd api,npm run buildandnpm start
 
- Copy 
Webapp
- Adding new Module (Eg: Users):
- Create folder usersunder/webapp/src/app/pages/
- Create your Module and Component under /webapp/src/app/pages/users
- Add users.action.tswhere all your Redux Action Types and Actions will reside (refer/webapp/src/app/@shared/store/actions/users.action.ts)
- Add users.reducer.tswhere all your respective Reducers will recide (refer/webapp/src/@shared/store/reducers/users.reducer.ts)
- Add users.service.tswhere all your respective Services will recide (refer/webapp/src/@shared/services/users.service.ts)
- Add users.effect.tswhere all your respective Effects will recide (refer/webapp/src/@shared/store/reducers/users.effect.ts)
- Import the module state in /webapp/src/@shared/store/to make it avaliable to the app
- Import the Users Effect in /webapp/src/@core/core.module.ts
- Encapsulate all your User related code in /webapp/src/app/pages/users
- Adding new Route (Eg: /users):
- Add a new entry to PAGES_ROUTESobject in/webapp/src/app/pages/pages.routing.ts
 
- Create folder 
Sample GraphQL Queries
These queries are generated on client side using queryBuilder() helper defined in /webapp/src/app/@shared/utils/helpers.ts
| 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
    }
  }
}
                 |