- Node.js 8+
- MongoDB 3.6+ (Recommended 4+)
- Clone the project from github
git clone https://github.com/amitanwar/node-graphql-mongo-tutorial.git
- Download respository
- Uncompress to your desired directory
cd project
npm install
- Make copy of .env.tmpl to .env and update the required variables
cp .env.tmpl .env
- The file .env is already ignored, so you never commit your credentials.
app/
┣ graphql/
┃ ┣ resolvers/
┃ ┃ ┗ index.js
┃ ┗ schema/
┃ ┗ index.js
┣ helper/
┃ ┗ connection.js
┗ models/
┗ author.model.js
node app
or use nodemon
nodemon app
http://localhost:5000/graphq
- Query Request (Get author detail by name)
{
author(name: "") {
name
email
}
}
- Query Request (Get all authors)
{
authors {
name
email
}
}
- Mutation Request (Create new author)
mutation {
createAuthor(author: {name: "name", phoneNo: "phone", email: "email", address: "address"}) {
_id
name
}
}
This project is open-sourced software licensed under the MIT License. See the LICENSE file for more information.