Skip to content

A Node GraphQL server template built with ES2021, Node 15, GraphQL, Express, Express-GraphQL. High-integrity Integration Testing with SuperTest, Mocha, and Chai. Containerization with Docker. Continuous Integration with Travis-CI and Github.

License

Notifications You must be signed in to change notification settings

nolindnaidoo/enterprise-graphql-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub package.json version Node Travis (.org) GitHub repo size GitHub

Enterprise GraphQL Server

Core Libraries

A Node GraphQL server template built with ES2021 Node, GraphQL, Express, Express-GraphQL. High-integrity Integration Testing with SuperTest, Mocha, and Chai. Containerization with Docker. Continuous Integration with Travis-CI and Github.

Quick Start

Scripts

Server is deployed at http://localhost:3001/graphql

Development

  • yarn start - Deploy Development Server
  • yarn test - Run Test Cases

Production

  • yarn run build - Deploy Production Server
  • yarn run buildDocker - Build Docker Image & Deploy Docker Container

See package.json for full list of scripts

Example Usage

GraphiQL with queries

http://localhost:3001/graphql?query=%0A%23%20Query%3A%20get%20all%20objects%0Aquery%20%7B%0A%20%20getObjects%20%7B%0A%20%20%20%20GraphQLBoolean%0A%20%20%20%20GraphQLFloat%0A%20%20%20%20GraphQLID%0A%20%20%20%20GraphQLInt%0A%20%20%20%20GraphQLString%0A%20%20%7D%0A%7D%0A%0A%23%20Query%3A%20get%20a%20single%20object%0A%23%20query%20%7B%0A%23%20%20%20getObject(GraphQLID%3A%201)%20%7B%0A%23%20%20%20%20%20GraphQLBoolean%0A%23%20%20%20%20%20GraphQLFloat%0A%23%20%20%20%20%20GraphQLID%0A%23%20%20%20%20%20GraphQLInt%0A%23%20%20%20%20%20GraphQLString%0A%23%20%20%20%7D%0A%23%20%7D%0A%0A%23%20Mutation%3A%20Add%20a%20single%20object%20by%20ID%0A%23%20mutation%20%7B%0A%23%20%20%20addObject(%20GraphQLBoolean%3A%20true%2C%20GraphQLFloat%3A%202%2C%20GraphQLID%3A%202%2C%20GraphQLInt%3A%202%2C%20GraphQLString%3A%20%22Object%202%22)%20%7B%0A%23%20%20%20%20%20GraphQLBoolean%0A%23%20%20%20%20%20GraphQLFloat%0A%23%20%20%20%20%20GraphQLID%0A%23%20%20%20%20%20GraphQLInt%0A%23%20%20%20%20%20GraphQLString%0A%23%20%20%20%7D%0A%23%20%7D%0A%0A%23%20Mutation%3A%20Update%20a%20single%20object%20by%20ID%0A%23%20mutation%20%7B%0A%23%20%20%20updateObject(GraphQLID%3A%202%2C%20GraphQLBoolean%3A%20false)%20%7B%0A%23%20%20%20%20%20GraphQLBoolean%0A%23%20%20%20%20%20GraphQLFloat%0A%23%20%09%09GraphQLID%0A%23%20%20%20%20%20GraphQLInt%0A%23%20%20%20%20%20GraphQLString%0A%23%20%20%20%7D%0A%23%20%7D%0A%0A%23%20Mutation%3A%20Delete%20a%20single%20object%20by%20ID%0A%23%20mutation%20%7B%0A%23%20%20%20deleteObject(GraphQLID%3A%202)%20%7B%0A%23%20%20%20%20%20GraphQLBoolean%0A%23%20%20%20%20%20GraphQLFloat%0A%23%20%20%20%20%20GraphQLID%0A%23%20%20%20%20%20GraphQLInt%0A%23%20%20%20%20%20GraphQLString%0A%23%20%20%20%7D%0A%23%20%7D

Query: getObjects

Return all objects
query {
  getObjects {
    GraphQLBoolean
    GraphQLFloat
    GraphQLID
    GraphQLInt
    GraphQLString
  }
}

Query: getObject

Return an object by ID
query {
  getObject(GraphQLID: 0) {
    GraphQLBoolean
    GraphQLFloat
    GraphQLID
    GraphQLInt
    GraphQLString
  }
}

Mutation: addObject

Add an object by ID
mutation {
  addObject( GraphQLBoolean: true, GraphQLFloat: 2, GraphQLID: 2, GraphQLInt: 2, GraphQLString: "Object 2") {
    GraphQLBoolean
    GraphQLFloat
    GraphQLID
    GraphQLInt
    GraphQLString
  }
}

Mutation: updateObject

Update an object by ID
mutation {
  updateObject(GraphQLID: 2, GraphQLBoolean: true) {
    GraphQLBoolean
    GraphQLFloat
    GraphQLID
    GraphQLInt
    GraphQLString
  }
}

Mutation: deleteObject

Remove an object by ID
mutation {
  deleteObject(GraphQLID: 2) {
    GraphQLBoolean
    GraphQLFloat
    GraphQLID
    GraphQLInt
    GraphQLString
  }
}

Development Setup

Environment

  • Install NVM (Optional)
  • Install Node (Node 10+)
  • Install Yarn
  • Install Docker Desktop
  • Install Git and run these commands to configure it:
    • > git config --global user.name "{FULL_NAME}"
    • > git config --global user.email {EMAIL}
    • > git config --global core.autocrlf false.
    • Refer to Advanced Git Configuration for additional information
  • Setup SSH Key
  • Clone Repository git clone https://github.com/nolindnaidoo/enterprise-graphql-server.git

"type": "module", - It uses modules with import/export instead of CommonJS require.

API Testing

  • SuperTest HTTP assertions made easy via superagent.
  • Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun.
  • Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework.

Continuous Integration & Deployment

The following links provide enhanced awareness throughout the Agile SDLC process. Save as bookmarks for rapid development.

Linting & Beautification

ESLint with Airbnb Config for lint/syntax errors. Prettier for automated formatting and lint error fixing on file save. (Configure your editor)

Exceptions

Git

The Git Feature Branch Workflow is a composable workflow that can be leveraged by other high-level Git workflows. This project utilizes the Github Flow, which allows for fast-paced and high-quality parallel development.

Github Flow:

  • Create the branch. Make sure it begins with the feature/, hotfix/, bugfix/, semver/ prefix.
  • Add commits
  • Open a Pull Request
  • Review & Collaborate changes
  • Deploy and Test
  • Merge

Merging from Main

A best practice is to perform merging when the working tree is clean. Use caution, first commit any unfinished work still desired, or reset the Git working tree. Choose > git stash and save the working tree until ready. Alternatively, reset the working tree. > git reset --hard

Staying up-to-date with the latest from main is beneficial to parallel development. Remote main represents the most stable and approved iteration of the product. In Parallel Development, updates to main may affect current implementation. Work with the latest from main by merging the latest from main into feature/{name} as frequently as possible, but only when necessary.

Merging from Main Procedure

  • > git reset --hard or > git stash
  • > git checkout main
  • > git pull
  • > git checkout "feature/{name}"
  • > git merge main
  • No Conflicts: Auto-merge Successful
  • Conflicts: Resolve Conflicts and run:
    • > git add .
    • > git commit -m "merge main, resolved conflicts"
    • > git push

Merging to Main

  • Make sure your feature branch is not behind the main. You can view it from the Branch Status view in the Behind/Ahead column.
  • Verify that your feature branch builds successfully on TravisCI.
  • Check your coverage against main. The Feature Branch should be greater than or equal to the main.
  • Resolve or reply to all Pull Request comments.
  • Use the Merge button on the Pull Request to merge back to main.
  • Once the test is successful and no further changes are needed for sign off delete the original feature branch.

IDE's

Take advantage of advanced workflow features by using supported IDE's with the appropriate plugins.

Atom

  • Install Atom
  • Install Packages
    • atom-css-clean
    • autoclose-html
    • autocomplete-json
    • autocomplete-modules
    • busy-signal
    • file-icons
    • highlight-selected
    • html-escaper
    • intentions
    • language-babel
    • linter
    • linter-eslint
    • linter-htmlhint
    • linter-ui-default
    • markdown-preview-enhanced
    • pigments
    • prettier-atom
    • sort-lines
    • terminal-panel-uoa

Visual Studio Code

  • Install Visual Studio Code
  • Install Packages
    • christian-kohler.path-intellisense
    • dbaeumer.vscode-eslint
    • donjayamanne.githistory
    • emmanuelbeziat.vscode-great-icons
    • esbenp.prettier-vscode
    • formulahendry.auto-close-tag
    • vstirbu.vscode-mermaid-preview
    • wayou.vscode-todo-highlight
    • zhuangtongfa.Material-theme

About

A Node GraphQL server template built with ES2021, Node 15, GraphQL, Express, Express-GraphQL. High-integrity Integration Testing with SuperTest, Mocha, and Chai. Containerization with Docker. Continuous Integration with Travis-CI and Github.

Topics

Resources

License

Stars

Watchers

Forks