- Create employee records that include first name, last name, email address, and department.
- Read, update, and delete record(s).
- Plus icon on the top right to add an employee
- Edit/pencil icon to update a record
- Delete/trash icon to remove a record
- The datatable has search and sort functionalities.
Make sure you have Node.js and the Heroku CLI installed.
- Download and install
$ git clone https://github.com/gregorifaroux/nodereactgraphql.git # or clone your own fork
$ cd nodereactgraphql
$ npm install- Setup database connection by creating a
.envfile in the server directory
$ cp server/.env.sample server/.env
$ vi server/.env
Set the MONGODB_URI to your local mongodb or a mlab instance.- Run the server and web client
$ npm startYour app should now be running on localhost:3000.
- If you get a network error 'failed to fetch', please look at the server log; more likely the server could not connect to the mongodb instance.
$ heroku create
$ git push heroku master
$ heroku open
or
Make sure you have Node.js and the Heroku CLI installed.
$ git clone https://github.com/gregorifaroux/nodereactgraphql.git # or clone your own fork
$ cd nodereactgraphql
$ npm install
$ npm run build
$ npm run start:prod- Rate limit
- Depth Limiting graphql-depth-limit
- Amount Limiting - Restrict maximum record of findMany
index.js: Server set upschemas/: Queries and Mutationsmodels/: Employee Information model ( Mongoose models )
- Created via
create-react-app - Airbnb lint & pre-commit hooks to run lint and prettier
- User @apollo/react-hooks and apollo-boost
- Use Hooks for state management and API calls
- Form via react-hook-form
- Data table via react-bootstrap-table-next
- UI Bootstrap components via reactstrap
EmployeeList: Main datatable with add, edit, and delete actions.AddEmployee: API calls to create a new employee and useEmployeeFormto collect and validate the data.EditEmployee: API calls to edit and useEmployeeFormto collect and validate the data.EmployeeForm: React Hook form used to create or to edit employee records.DeleteEmployee: Confirmation page instead of using the traditional modal.
The first approach is to install Mongo locally. In order to so, go to https://docs.mongodb.com/manual/administration/install-community/ and follow the instructions based on your operating system.
The second option is to create a FREE database hosted on mLab and then connect your application to the remote instance. To do so, go to mLab and create a sandbox Mongo instance. Then, go to the Users tab in your mLab-sandbox-MongoDB-instance-dashboard and click on the 'add a database user' button; setup username and password. Remember those values, we'll need them shortly!
Inside both 'server' and 'client' folders there is a .env.sample file. Create a new file called .env based on the provided .env.sample.
