Explore the docs »
View Demo
·
View GIFs
·
Demonstration Video
·
Report Bug
·
Request Feature
Table of Contents
This is a basic user listing app where you can create new users using GraphQL Mutation (See: GraphQL Mutations and Queries ) and fetch them using Query but also having the server-side form and input validations like empty fields, wrong user role, not matching passwords, format validation, and already used email check. There is also custom rate limiting (See: Rate Limiting ) configure so users can not create too many users in a limited time which may prevent or limit the server costs and also enhance security.
To get a local copy up and running follow these simple steps.
-
git
if (you have brew installed ) { use this command => 'brew install git' } else { download the installer from the official website => https://git-scm.com/downloads }
-
node
if (you have brew installed) { use this command => 'brew install node' } else { download the installer from the official website => https://nodejs.org/en/ }
What is brew ?? (See: Homebrew Package Manager)
This repo/project has two different branches/directories for different use
main/server branch (root directory) for server side (graphql)
client branch (client directory) for client side (react)
- Clone the repo
git clone https://github.com/felmez/user-listing.git
- Install npm packages on both branches
cd user-listing
on main branch/directory npm install on client branch/directory git checkout client (* optional for separation of concerns) npm install
- Create environment variables
if (you will serve on localhost) {
if (on main branch/directory) {
3.1 - create config.js file
3.2 - paste the follow code
```
module.exports = {
MONGODB: 'mongodb+srv://<username>:<password>@<clustername>.<linkprefix>.mongodb.net/<dbname>?retryWrites=true&w=majority'
}
```
3.3 - change the URI strings to your own MongoDB credentials
}
if (on client branch/directory) {
3.4 - on ApolloProvider.js change uri to your server link
}
} else if (you will use some SaaS hosting services like heroku, netlify etc){
use process.ENV configurations depending on your service type
}
- You are good to go
on main branch/directory =>
if (you need to watch changes) {
'nodemon index'
} else {
'node index'
}
on client branch/directory =>
'npm start'
- Sample GraphQL requests
query Query {
getUsers {
email
id
name
}
}
mutation Mutation{
createUser(createInput:{
name: "john doee"
email: "johnnny@idkk.com"
role: "normal"
password: "New12345@"
confirmPassword: "New12345@"
})
{
id
name
email
role
}
}
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Souhaib Felmez