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.
Server is deployed at http://localhost:3001/graphql
Development
yarn start
- Deploy Development Serveryarn test
- Run Test Cases
Production
yarn run build
- Deploy Production Serveryarn run buildDocker
- Build Docker Image & Deploy Docker Container
See package.json for full list of scripts
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 {
GraphQLBoolean
GraphQLFloat
GraphQLID
GraphQLInt
GraphQLString
}
}
query {
getObject(GraphQLID: 0) {
GraphQLBoolean
GraphQLFloat
GraphQLID
GraphQLInt
GraphQLString
}
}
mutation {
addObject( GraphQLBoolean: true, GraphQLFloat: 2, GraphQLID: 2, GraphQLInt: 2, GraphQLString: "Object 2") {
GraphQLBoolean
GraphQLFloat
GraphQLID
GraphQLInt
GraphQLString
}
}
mutation {
updateObject(GraphQLID: 2, GraphQLBoolean: true) {
GraphQLBoolean
GraphQLFloat
GraphQLID
GraphQLInt
GraphQLString
}
}
mutation {
deleteObject(GraphQLID: 2) {
GraphQLBoolean
GraphQLFloat
GraphQLID
GraphQLInt
GraphQLString
}
}
- 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.
- 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.
The following links provide enhanced awareness throughout the Agile SDLC process. Save as bookmarks for rapid development.
ESLint with Airbnb Config for lint/syntax errors. Prettier for automated formatting and lint error fixing on file save. (Configure your editor)
- comma-dangle ["error", "never"]
- import/extensions off
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.
- 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
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.
> 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
- 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.
Take advantage of advanced workflow features by using supported IDE's with the appropriate plugins.
- 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
- 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